📄 ab_t1.hpp
字号:
void AB_T1W1A::GO ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_STR( ); // Select
AB_T1::W( 0x4, ( AB_T1::R( 0x4 ) & 0x7 ) | 0x8 );
AB_T1W1A::PAGE_END( ); // Select
AB_T1::W( 0x4, ( AB_T1::R( 0x4 ) & 0x7 ) | 0x8 );
delay(2);
AB_T1W1A::PAGE_TIM( ); // Select
AB_T1::W( 0x1, ( AB_T1::R( 0x1 ) & 0x7 ) | 0x8 );
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1W1A::STOP ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_TIM( ); // Select
AB_T1::W( 0x1, AB_T1::R( 0x1 ) & 0x7 );
AB_T1W1A::PAGE_END( ); // Select
AB_T1::W( 0x4, AB_T1::R( 0x4 ) & 0x7 );
AB_T1W1A::PAGE_STR( ); // Select
AB_T1::W( 0x4, AB_T1::R( 0x4 ) & 0x7 );
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
float AB_T1W1A::T_S ( ) // TimeUnit => Sec
{
return( AB_T1W1A::T_uS() / 1000000.0 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
float AB_T1W1A::T_mS ( ) // TimeUnit => mSec
{
return( AB_T1W1A::T_uS() / 1000.0 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
float AB_T1W1A::T_uS ( ) // TimeUnit => uSec
{
unsigned BASE_SEL;
int TIME;
float BASE;
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_TIM( ); // Select
BASE_SEL = AB_T1::R( 0x4 );
if ( BASE_SEL & 0x8 ) BASE = 512.0;
else if( BASE_SEL & 0x4 ) BASE = 64.0;
else if( BASE_SEL & 0x2 ) BASE = 8.0;
else BASE = 1.0;
TIME = (int) AB_T1::R( 0x7 );
TIME = (TIME << 4) | (int) AB_T1::R( 0x6 );
TIME = (TIME << 4) | (int) AB_T1::R( 0x5 );
return( (float) TIME * BASE );
}
else
return( -1.0 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::STR_D ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_STR( ); // Select
return( (AB_T1::R( 0x4 ) & 0x4)? 1 : 0 );
}
else
return( -1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::END_D ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_END( ); // Select
return( (AB_T1::R( 0x4 ) & 0x4)? 1 : 0 );
}
else
return( -1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::STU_GO ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1::S( AB_T1W1A::EXT ); // Select
return( (AB_T1::R( 0x1 ) & 0x8)? 1 : 0 );
}
else
return( -1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::STU_T ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_TIM( ); // Select
return( (AB_T1::R( 0x3 ) & 0x8)? 1 : 0 );
}
else
return( -1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::STU_R ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_TIM( ); // Select
return( (AB_T1::R( 0x3 ) & 0x4)? 1 : 0 );
}
else
return( -1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::STU_E ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_TIM( ); // Select
return( (AB_T1::R( 0x3 ) & 0x2)? 1 : 0 );
}
else
return( -1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::STU_O ( )
{
if( !AB_T1W1A::ERR_NO() )
{
AB_T1W1A::PAGE_TIM( ); // Select
return( (AB_T1::R( 0x3 ) & 0x1)? 1 : 0 );
}
else
return( -1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1W1A::ERR_NO ( void )
{
return( AB_T1W1A::Err | AB_T1C1A::Err[AB_T1::ID] | AB_T1::Err[AB_T1::ID] );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1W1A::DA_12bit ( int CH, unsigned int D )
{
union { unsigned int DATA;
struct { unsigned D0 : 4;
unsigned D1 : 4;
unsigned D2 : 4;
unsigned D3 : 4; } PART; } DA_BUF;
if( !AB_T1W1A::ERR_NO() )
{
DA_BUF.DATA = D;
// Select Page
if( CH )
AB_T1W1A::PAGE_END();
else
AB_T1W1A::PAGE_STR();
// Write Data
AB_T1::W( 0x7, DA_BUF.PART.D2 );
AB_T1::W( 0x6, DA_BUF.PART.D1 );
AB_T1::W( 0x5, DA_BUF.PART.D0 );
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1W1A::AD_Path ( unsigned N )
{
if( !AB_T1W1A::ERR_NO() )
{
if ( N & 0x8 ) N = 0x8;
else if( N & 0x4 ) N = 0x4;
else if( N & 0x2 ) N = 0x2;
else N = 0x1;
// Select
AB_T1::S( AB_T1W1A::EXT );
// Write Data
AB_T1::W( 0x2, N );
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1W1A::PAGE_TIM ( )
{
if( !AB_T1W1A::ERR_NO() ) {
AB_T1::S( AB_T1W1A::EXT );
AB_T1::W( 0x1, ( AB_T1::R( 0x1 ) & 0x8 ) | 0x4 );
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1W1A::PAGE_STR ( )
{
if( !AB_T1W1A::ERR_NO() ) {
AB_T1::S( AB_T1W1A::EXT );
AB_T1::W( 0x1, ( AB_T1::R( 0x1 ) & 0x8 ) | 0x2 );
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1W1A::PAGE_END ( )
{
if( !AB_T1W1A::ERR_NO() ) {
AB_T1::S( AB_T1W1A::EXT );
AB_T1::W( 0x1, ( AB_T1::R( 0x1 ) & 0x8 ) | 0x1 );
}
}
//=< AB_T1H1A >==============================================================//
// //
// //
// //
// //
//===========================================================================//
class AB_T1H1A :public AB_T1C1A {
public:
AB_T1H1A ( unsigned int P );
AB_T1H1A ( unsigned int P, unsigned EXT );
unsigned LOC ( );
unsigned LOC ( unsigned EXT );
void INIT ( );
int WHERE ( );
unsigned ID ( );
unsigned IN ( );
void OUT ( unsigned MODE, unsigned BYTE );
void OUT ( unsigned MODE );
void OUT_SET ( unsigned BYTE );
void OUT_SET ( );
void OUT_HI ( unsigned BYTE );
void OUT_HI ( );
void OUT_LOW ( unsigned BYTE );
void OUT_LOW ( );
void OUT_CLR ( );
unsigned OUT_STU ( );
int ERR_NO ( );
private:
static int USED[4];
unsigned EXT;
int Err;
};
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1H1A::USED[4] = { 0, 0, 0, 0 };
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
AB_T1H1A::AB_T1H1A ( unsigned int P )
:AB_T1C1A ( P )
{
int error=1;
unsigned LOC_TMP=0x2F;
for( unsigned S=0x20; !AB_T1::Err[AB_T1::ID] && (S<=0x23); S++ )
if( (AB_T1::C_ID(S) & 0xE) == 0x08 )
if( LOC_TMP == 0x2F ) {
LOC_TMP = S;
error = 0;
} else
error = 1;
AB_T1H1A::LOC( (error)?0:(LOC_TMP-0x1F) );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
AB_T1H1A::AB_T1H1A ( unsigned int P, unsigned EXT )
:AB_T1C1A ( P )
{
AB_T1H1A::LOC( EXT );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
unsigned AB_T1H1A::LOC ( )
{
return( (AB_T1H1A::EXT==0x2F)? 0 : (AB_T1H1A::EXT-0x1F) );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
unsigned AB_T1H1A::LOC ( unsigned EXT )
{
AB_T1H1A::Err = 0;
if( (1 > EXT) || (EXT > 4) ) {
AB_T1H1A::EXT = 0x2F;
AB_T1H1A::Err |= 0x100;
} else if( AB_T1H1A::USED[EXT-1] ) {
AB_T1H1A::EXT = 0x2F;
AB_T1H1A::Err |= 0x100;
} else if( (AB_T1::C_ID( 0x1F+EXT ) & 0xE) != 0x08 ) {
AB_T1H1A::EXT = 0x2F;
AB_T1H1A::Err |= 0x100;
} else {
AB_T1H1A::USED[EXT-1] = 1;
AB_T1H1A::EXT = 0x1F + EXT;
AB_T1H1A::INIT();
}
return( AB_T1H1A::LOC() );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::INIT ( )
{
AB_T1H1A::Err = 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1H1A::WHERE ( )
{
int WHERE_TMP = 0;
for( unsigned S=0x23; !AB_T1::Err[AB_T1::ID] && (S>=0x20); S-- ) {
WHERE_TMP <<= 1;
if( (AB_T1::C_ID(S) & 0xE) == 0x08 )
WHERE_TMP |= 1;
}
return( WHERE_TMP );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
unsigned AB_T1H1A::ID ( )
{
if( !AB_T1::Err[AB_T1::ID] )
{
AB_T1::S( AB_T1H1A::EXT ); // Select
return( AB_T1::R( 0x2 ) );
}
else
return( 0x0 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
unsigned AB_T1H1A::IN ( )
{
if( !AB_T1::Err[AB_T1::ID] )
{
AB_T1::S( AB_T1H1A::EXT ); // Select
return( AB_T1::R( 0x3 ) );
}
else
return( 0x0 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT ( unsigned MODE, unsigned BYTE )
{
union { unsigned DATA;
struct { unsigned D0 : 4;
unsigned D1 : 4; } PART; } DATA_BUF;
if( !AB_T1::Err[AB_T1::ID] )
{
DATA_BUF.DATA = BYTE;
AB_T1::S( AB_T1H1A::EXT ); // Select
AB_T1::W( 0x5, DATA_BUF.PART.D1 );// Write Data
AB_T1::W( 0x4, DATA_BUF.PART.D0 );
AB_T1::W( 0x2, MODE ); // Update
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT ( unsigned MODE )
{
if( !AB_T1::Err[AB_T1::ID] )
{
AB_T1::S( AB_T1H1A::EXT ); // Select
AB_T1::W( 0x2, MODE ); // Update
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT_SET ( unsigned BYTE )
{
AB_T1H1A::OUT( 0x8, BYTE );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT_SET ( )
{
AB_T1H1A::OUT( 0x8 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT_HI ( unsigned BYTE )
{
AB_T1H1A::OUT( 0x4, BYTE );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT_HI ( )
{
AB_T1H1A::OUT( 0x4 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT_LOW ( unsigned BYTE )
{
AB_T1H1A::OUT( 0x2, BYTE );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT_LOW ( )
{
AB_T1H1A::OUT( 0x2 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
void AB_T1H1A::OUT_CLR ( )
{
AB_T1H1A::OUT( 0x1 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
unsigned AB_T1H1A::OUT_STU ( )
{
union { unsigned DATA;
struct { unsigned D0 : 4;
unsigned D1 : 4; } PART; } DATA_BUF;
if( !AB_T1::Err[AB_T1::ID] )
{
AB_T1::S( AB_T1H1A::EXT ); // Select
DATA_BUF.PART.D1 = AB_T1::R( 0x7 );// Read Data
DATA_BUF.PART.D0 = AB_T1::R( 0x6 );
return( DATA_BUF.DATA );
}
else
return( 0x0 );
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
int AB_T1H1A::ERR_NO ( void )
{
return( AB_T1H1A::Err | AB_T1C1A::Err[AB_T1::ID] | AB_T1::Err[AB_T1::ID] );
}
//===========================================================================//
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -