00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __RB8515_CLOCK_H
00026 #define __RB8515_CLOCK_H
00027
00028 #ifndef __RULBUSDEVICE_H
00029 #include "RulbusDevice.h"
00030 #endif
00031
00032 namespace Rulbus
00033 {
00034 DECLARE_CLASS( RB8515_clock );
00035
00166 class RB8515_clock: public RulbusDevice
00167 {
00168 public:
00172
00173 RB8515_clock( NameCref name, Addr addr = DEF_ADDR, Rack rack = DEF_RACK );
00174
00175 ~RB8515_clock();
00176
00180
00181 Freq clockFrequency () const;
00182 Freq interruptFrequency () const;
00183
00184 bool isPendingInterrupt () ;
00185 bool isEnabledInterrupt () const;
00186
00190
00191 void setClockFrequency ( Freq aFrequency );
00192 void setInterruptFrequency ( Freq aFrequency );
00193
00194 void clearInterrupt ();
00195
00196 bool disableInterrupt ();
00197 bool enableInterrupt ( bool enable = true );
00198
00200
00201 protected:
00204
00205 RB8515_clock();
00206 RB8515_clock( RB8515_clockCref rhs );
00207 RB8515_clockRef operator= ( RB8515_clockCref rhs );
00208
00210
00211 private:
00214
00215 Byte theCtlByte;
00216
00220
00221 enum
00222 {
00223 FC_INVALID = -1,
00224 FC_0Hz = 0,
00225 FC_100Hz,
00226 FC_1kHz,
00227 FC_10kHz,
00228 FC_100kHz,
00229 FC_1MHz,
00230 FC_10MHz,
00231 FC_100MHz,
00232 };
00233
00237
00238 enum
00239 {
00240 FI_INVALID = -1,
00241 FI_0Hz = 0,
00242 FI_1Hz,
00243 FI_5kHz,
00244 FI_10Hz,
00245 FI_50Hz,
00246 FI_100Hz,
00247 FI_500Hz,
00248 FI_1kHz,
00249 };
00250
00254
00255 static const int OFF_CR = 0;
00256 static const int OFF_SR = 0;
00257 static const int ADR_WIDTH = OFF_SR + 1;
00258
00262
00263 static const int MSK_CLKFRQ = 0x07;
00264 static const int MSK_INTFRQ = 0x38;
00265 static const int MSK_INTENA = 0x40;
00266 static const int MSK_INTCLRn = 0x80;
00267 static const int MSK_INTSTS = 0x80;
00268
00269 static const int SHL_CLKFRQ = 0x00;
00270 static const int SHL_INTFRQ = 0x03;
00271
00275
00276 static const Addr DEF_ADDR = 0xC8;
00277 static const Freq DEF_CLKFRQ ;
00278 static const Freq DEF_INTFRQ ;
00279
00283
00291 struct FreqTable
00292 {
00293 Freq freq;
00294 Int code;
00295 };
00296
00297 static FreqTable clkTable[];
00298 static FreqTable intTable[];
00299
00301
00302 protected:
00303 void getClkFreqCode( Freq aFrequency, IntPtr pCode ) const;
00304 void getIntFreqCode( Freq aFrequency, IntPtr pCode ) const;
00305 void getFreqCode ( Freq aFrequency, const FreqTable *tablePtr, IntPtr pCode ) const;
00306 };
00307
00309
00314 inline RB8515_clockRef to_rb8515( RulbusDevicePtr p )
00315 {
00316 return PROXY_CAST<RB8515_clockRef>( *p );
00317 }
00318
00323 inline RB8515_clockPtr to_rb8515_ptr( RulbusDevicePtr p )
00324 {
00325 return PROXY_CAST<RB8515_clockPtr>( p );
00326 }
00327
00328 }
00329
00330 #endif // __RB8515_CLOCK_H
00331
00332
00333
00334
00335