00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015   
00016 
00017 #ifndef TPU_H
00018 
00019 #define TPU_H
00020 
00021 #include <config.h>
00022 
00023 #define TPU_ADDR(nr)  (TPU_BASE + nr)
00024 
00025 #define TPU_TPUMCR      TPU_ADDR(0x0)  
00026 #define TPU_TICR        TPU_ADDR(0x08) 
00027 #define TPU_CIER        TPU_ADDR(0x0a) 
00028 #define TPU_CFSR        TPU_ADDR(0x0c) 
00029 #define TPU_CFSR0       TPU_ADDR(0x0c) 
00030 #define TPU_CFSR1       TPU_ADDR(0x0e) 
00031 #define TPU_CFSR2       TPU_ADDR(0x10) 
00032 #define TPU_CFSR3       TPU_ADDR(0x12) 
00033 #define TPU_HSQR        TPU_ADDR(0x14) 
00034 #define TPU_HSQR0       TPU_ADDR(0x14) 
00035 #define TPU_HSQR1       TPU_ADDR(0x16) 
00036 #define TPU_HSRR        TPU_ADDR(0x18) 
00037 #define TPU_HSRR0       TPU_ADDR(0x18) 
00038 #define TPU_HSRR1       TPU_ADDR(0x1a) 
00039 #define TPU_CPR         TPU_ADDR(0x1c) 
00040 #define TPU_CPR0        TPU_ADDR(0x1c) 
00041 #define TPU_CPR1        TPU_ADDR(0x1e) 
00042 #define TPU_CISR        TPU_ADDR(0x20) 
00043 #define TPU_PARAMETER   TPU_ADDR(0x100) 
00044 
00045 
00046 #define setTPUMCR(val)  writeshort(TPU_TPUMCR,val)
00047 #define setTICR(val)    writeshort(TPU_TICR,val)
00048 #define setCIER(ch,val) writeshortpos(TPU_CIER,val,0x1,ch)
00049 #define setCFSR(ch,val) writeshortpos(TPU_CFSR + ((3-(ch/4))<<1),val,0xf,(ch&0x3)<<2)
00050 #define setHSQR(ch,val) writeshortpos(TPU_HSQR+((1-(ch/8))<<1),val,0x3,(ch&0x7)<<1)
00051 #define setHSRR(ch,val) writeshortpos(TPU_HSRR+((1-(ch/8))<<1),val,0x3,(ch&0x7)<<1)
00052 #define setCPR(ch,val)  writeshortpos(TPU_CPR+((1-(ch/8))<<1),val,0x3,(ch&0x7)<<1)
00053 #define clearCISR(ch)   writeshortpos(TPU_CISR,0x0,0x1,ch)
00054 #define setPAR(ch,nr,val) writeshort(TPU_PARAMETER+(ch*16)+(nr<<1),val)
00055 
00056 #define getTPUMCR()     readshort(TPU_TPUMCR)
00057 #define getTICR()       readshort(TPU_TICR)
00058 #define getCIER(ch)     readshortpos(TPU_CIER,0x1,ch)
00059 #define getCFSR(ch)     readshortpos(TPU_CFSR + ((3-(ch/4))<<1),0xf,(ch&0x3)<<2)
00060 #define getHSQR(ch)     readshortpos(TPU_HSQR+((1-(ch/8))<<1),0x3,(ch&0x7)<<1)
00061 #define getHSRR(ch)     readshortpos(TPU_HSRR+((1-(ch/8))<<1),0x3,(ch&0x7)<<1)
00062 #define getCPR(ch)      readshortpos(TPU_CPR+((1-(ch/8))<<1),0x3,(ch&0x7)<<1)
00063 #define getCISR(ch)     readshortpos(TPU_CISR,0x1,ch)
00064 #define getPAR(ch,nr)   readshort(TPU_PARAMETER+(ch*16)+(nr<<1))
00065 
00066 #define TPU_FKT_PPWA 0xf
00067 #define TPU_FKT_OC   0xe
00068 #define TPU_FKT_SM   0xd
00069 #define TPU_FKT_PSP  0xc
00070 #define TPU_FKT_PMA  0xb
00071 #define TPU_FKT_ITC  0xa
00072 #define TPU_FKT_PWM  0x9
00073 #define TPU_FKT_DIO  0x8
00074 #define TPU_FKT_SPWM 0x7
00075 #define TPU_FKT_QDEC 0x6
00076 
00077 #define TPU_QDEC_EDGE_TIME 0
00078 #define TPU_QDEC_POS_COUNT 1
00079 #define TPU_QDEC_TCR1_VAL 2
00080 #define TPU_QDEC_CHAN_PINSTATE 3
00081 #define TPU_QDEC_CORR_PINSTATE_ADDR 4
00082 #define TPU_QDEC_EDGE_TIME_LSB_ADDR 5
00083 
00084 #endif