00001 /* 00002 Object Oriented Mobile Robot Model (OOMRM) C++ Library Copyright (C) 2002-2005 Derek Jones 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Lesser General Public 00006 License as published by the Free Software Foundation; either 00007 version 2.1 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public 00015 License along with this library; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 $Id: oomrm.h,v 1.2 2007/06/10 22:41:28 derek Exp $ 00019 */ 00020 #ifndef _OOMRM_H 00021 #define _OOMRM_H 00022 #include "sim_regs.h" 00023 #include <utility/status.h> 00024 #include "oprocessor.h" 00025 #include "otpu.h" 00026 #include "oqsm.h" 00027 #include "ovbr.h" 00028 /* system clock */ 00029 #define FCRYSTAL 32768L 00030 #define SYSCLK (FCRYSTAL * 4 * (((((*(word *) 0xfffa04) >> 8) & 0x3f) + 1) << (((*(word *) 0xfffa04) >> 14) & 0x3))) 00031 //#define SYSCLK ((FCRYSTAL*4*(SYSCLK_Y + 1)*(1<<(2*SYSCLK_W + SYSCLK_X)))) 00032 #define SPIBAUD(baud) (((SYSCLK >> 1)+((long)(baud)/2))/(baud)) 00033 //#define qspidivider(baud) (((SYSCLK >> 1)+((long)(baud)/2))/(baud)) 00034 //#define SPIBAUD(x) (SYSCLK/(2*(long)x)) 00035 #ifdef DOS 00036 #define SCIBAUD(x) (x) 00037 #else 00038 #define SCIBAUD(x) (SYSCLK/(32*x)) 00039 #endif 00040 #define DEFAULT_BAUD 19200 00041 /* 00042 // Interrupt priority levels 00043 All on-chip peripherals are assigned an interrupt request level from zero to seven. 00044 Seven is the highest priority, one is the lowest, and zero disables any interrupt requests. 00045 */ 00046 // TPU has high speed devices UARTs (bluetooth) and encoders. 00047 #define OOMRM_TPU_LEVEL 6 00048 // Other Serial communication come next. 00049 #define OOMRM_QSPI_LEVEL 5 00050 #define OOMRM_SCI_LEVEL 4 00051 // PIT Usually used for scheduler task switching--hardware (SCI/SPI/UART(TPU)) should be higher priority. 00052 #define OOMRM_PIT_LEVEL 3 00053 /* 00054 // Arbitration Levels 00055 The same interrupt priority level can be assigned to more than one module. For example, 00056 the TPU and the QSM can both be assigned interrupt level five. If both the TPU 00057 and the QSM interrupt the CPU simultaneously, then the interrupt arbitration (IARB) 00058 fields in the respective module configuration registers determine which module is serviced 00059 first. 00060 The IARB field is essentially a second-level priority in case of a tie. Each module that 00061 has an interrupt priority level also has an IARB field. Each module must be assigned 00062 a unique non-zero IARB value, or operation is undefined when interrupts with the 00063 same priority level are issued simultaneously. 00064 IARB fields contain four bits. An IARB value of %1111 is the highest arbitration priority, 00065 %0001 is the lowest, and %0000 disables interrupt arbitration. Whereas zero in the interrupt 00066 priority level field disables a module from requesting an interrupt, a zero in the 00067 IARB field disables a module from acknowledging its interrupt request. If a module with 00068 a non-zero interrupt priority field and a zero IARB field requests an interrupt, the CPU 00069 sees a spurious interrupt, because the module requesting the interrupt service never 00070 confirms that it made the request. 00071 */ 00072 #define DEFAULT_PIT_IARB 4 00073 #define DEFAULT_TPU_IARB 0xE 00074 00075 #define SCI_QUEUE_SIZE 160 00076 #define RX 0 00077 #define TX 1 00078 // I should probably reconsider all the global constants here; nice to say "#include <hardware/oomrm.h> and it will include 00079 // everything, but sometimes the interrupt C routines need these requiring to "shut off" C++ constructs. 00080 #ifdef __cplusplus 00081 00082 00088 00089 #ifdef DOS 00090 class OOMRM : 00091 public oTPU 00092 #else 00093 class OOMRM : 00094 public oVBR, 00095 public oProcessor, 00096 public oQSM, 00097 public oTPU 00098 #endif 00099 { 00100 public: 00101 OOMRM(); 00102 // static oRedLED RedLED; 00103 // static oGreenLED GreenLED; 00104 #ifdef DOS 00105 // static TPU_T* TPU_BASE; 00106 static TPU_T* TPU; 00107 static SIM_T* SIM; 00108 static QSM_T* QSM; 00109 #endif 00110 }; 00111 #endif 00112 #endif
1.3