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
00026
00027 #ifndef CEYLAN_FIFO_H_
00028 #define CEYLAN_FIFO_H_
00029
00030 #include "CeylanARM7Codes.h"
00031 #include "CeylanTextDisplayable.h"
00032 #include "CeylanSystem.h"
00033 #include "CeylanTypes.h"
00034 #include "CeylanSystemInformation.h"
00035
00036
00037
00038
00049 typedef Ceylan::Uint8 FIFOCommandCount ;
00050
00051
00052
00053
00054 namespace Ceylan
00055 {
00056
00057
00058
00059 namespace System
00060 {
00061
00062
00063
00065 typedef Ceylan::Uint32 FIFOElement ;
00066
00067
00068
00207 class CEYLAN_DLL FIFO: public Ceylan::TextDisplayable
00208 {
00209
00210
00211 public:
00212
00213
00214
00216 class FIFOException: public SystemException
00217 {
00218 public:
00219
00220 explicit FIFOException( const std::string & reason ) ;
00221
00222 virtual ~FIFOException() ;
00223
00224 } ;
00225
00226
00227
00229 class FIFOFull: public FIFOException
00230 {
00231 public:
00232
00233 explicit FIFOFull( const std::string & reason ) ;
00234
00235 } ;
00236
00237
00238
00240 class FIFOEmpty: public FIFOException
00241 {
00242 public:
00243
00244 explicit FIFOEmpty( const std::string & reason ) ;
00245
00246 } ;
00247
00248
00249
00250
00260 explicit FIFO() ;
00261
00262
00263
00265 virtual ~FIFO() throw() ;
00266
00267
00268
00269
00270
00271
00272
00274 virtual bool isActive() const ;
00275
00276
00277
00299 virtual void activate() ;
00300
00301
00302
00313 virtual void deactivate() ;
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00332 virtual ARM7StatusWord getLastARM7StatusWord() ;
00333
00334
00335
00343 virtual std::string interpretLastARM7StatusWord() ;
00344
00345
00346
00355 virtual ARM7ErrorCode getLastARM7ErrorCode() ;
00356
00357
00358
00366 virtual std::string interpretLastARM7ErrorCode() ;
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00394 virtual void sendBatteryStatusRequest() ;
00395
00396
00397
00412 virtual BatteryStatus getBatteryStatus() ;
00413
00414
00415
00426 virtual void sendDSTypeRequest() ;
00427
00428
00429
00444 virtual DSType getDSType() ;
00445
00446
00447
00460 virtual const std::string toString(
00461 Ceylan::VerbosityLevels level = Ceylan::high ) const ;
00462
00463
00464
00465
00466
00467
00468
00474 static FIFOCommandID GetFIFOCommandIDFrom(
00475 const FIFOElement & element ) ;
00476
00477
00478
00484 static FIFOCommandCount GetFIFOCommandCountFrom(
00485 const FIFOElement & element ) ;
00486
00487
00488
00497 static FIFOCommandCount GetARM7ProcessedCount() ;
00498
00499
00500
00509 static FIFOCommandCount GetARM9ProcessedCount() ;
00510
00511
00512
00530 static void VBlankHandlerForFIFO() ;
00531
00532
00533
00542 static FIFO & GetActivatedFIFO() ;
00543
00544
00545
00553 static FIFO & GetExistingFIFO() ;
00554
00555
00556
00563 static FIFO & GetFIFO() ;
00564
00565
00566
00575 static bool RemoveFIFO() ;
00576
00577
00578
00583 static FIFO * _FIFO ;
00584
00585
00586
00587
00588 protected:
00589
00590
00591
00604 virtual void handleReceivedCommand() ;
00605
00606
00607
00626 virtual void handleReceivedSystemSpecificCommand(
00627 FIFOCommandID commandID, FIFOElement firstElement ) ;
00628
00629
00630
00650 virtual void handleReceivedIntegratingLibrarySpecificCommand(
00651 FIFOCommandID commandID, FIFOElement firstElement ) ;
00652
00653
00654
00674 virtual void handleReceivedApplicationCommand(
00675 FIFOCommandID commandID, FIFOElement firstElement ) ;
00676
00677
00678
00688 virtual void handleUnexpectedApplicationCommand(
00689 FIFOCommandID commandID ) ;
00690
00691
00692
00711 virtual FIFOElement prepareFIFOCommand( FIFOCommandID id ) ;
00712
00713
00714
00723 virtual void notifyCommandToARM7() ;
00724
00725
00726
00732 virtual void sendSynchronizeInterruptToARM7() ;
00733
00734
00735
00741 bool dataAvailableForReading() const ;
00742
00743
00749 bool spaceAvailableForWriting() const ;
00750
00751
00752
00761 FIFOElement read() ;
00762
00763
00764
00775 FIFOElement readBlocking() ;
00776
00777
00778
00787 void write( FIFOElement toSend ) ;
00788
00789
00790
00801 void writeBlocking( FIFOElement toSend ) ;
00802
00803
00804
00809 FIFOCommandCount getProcessedCount() const ;
00810
00811
00812
00817 FIFOCommandCount getSentCount() const ;
00818
00819
00820
00826 virtual void incrementProcessedCount() ;
00827
00828
00829
00830
00831
00832
00833
00834
00835
00847 static void SyncHandlerForFIFO() ;
00848
00849
00850
00859 static void ManageReceivedCommand() ;
00860
00861
00862
00867 static std::string DescribeCommand( FIFOElement element ) ;
00868
00869
00870
00871
00872
00873
00886 ARM7StatusWord volatile * volatile _arm7StatusWordPointer ;
00887
00888
00889
00902 ARM7ErrorCode volatile * volatile _arm7ErrorCodePointer ;
00903
00904
00905
00919 volatile FIFOCommandCount _localCommandCount ;
00920
00921
00922
00935 volatile FIFOCommandCount _remoteCommandCount ;
00936
00937
00938
00949 volatile FIFOCommandCount _processedCount ;
00950
00951
00952
00963 volatile FIFOCommandCount _sentCount ;
00964
00965
00966
00973 volatile bool _activated ;
00974
00975
00976
00981 volatile System::BatteryStatus _batteryStatus ;
00982
00983
00984
00989 volatile System::DSType _dsType ;
00990
00991
00992
00993
00994 private:
00995
00996
00997
01006 FIFO( const FIFO & source ) ;
01007
01008
01009
01018 FIFO & operator = ( const FIFO & source ) ;
01019
01020
01021 } ;
01022
01023
01024 }
01025
01026 }
01027
01028
01029
01030 #endif // CEYLAN_FIFO_H_
01031