#include #include /* for rtems types. eg. for uint32_t that Read_timer returns */ #include /* for Timer_initialize() */ #include "drvMpsLinkNode.h" /* From Arcturus schematics, looks like PTC is really PTD */ #define IPSBAR (0x40000000) #define MPS_BASE_ADDR (0x80000000) #define CSAR1 (IPSBAR+0x00008C) /* 2 bytes */ #define CSMR1 (IPSBAR+0x000090) /* 4 bytes */ #define CSCR1 (IPSBAR+0x000096) /* 2 bytes */ #define VERSION (MPS_BASE_ADDR+0x0068) /* Register 26 */ /* Ref: www.freescale.com Chapter 12. Chip Select Module Base address of the Freescale registers */ #define PTDPAR (IPSBAR+0x0010005B) /* PORT Pin Assignment Register */ #define PORTTD (IPSBAR+0x00100010) /* General Purpose IO Port TD */ #define DDRTD (IPSBAR+0x00100024) /* General Purpose IO Port TD Direction */ LOCAL volatile unsigned char *ptdpar = (unsigned char *)PTDPAR; LOCAL volatile unsigned char *porttd = (unsigned char *)PORTTD; LOCAL volatile unsigned char *ddrtd = (unsigned char *)DDRTD; LOCAL volatile short *fpga_csar1 = (short *)CSAR1; LOCAL volatile unsigned short *fpga_cscr1 = (unsigned short *)CSCR1; LOCAL volatile unsigned long *fpga_csmr1 = (unsigned long *)CSMR1; LOCAL volatile unsigned long *fpga_version = (unsigned long *)VERSION; int mpsFPGAInitialise () { /* Used for re-programming the FPGA */ /* Setup Port C for Digital IO */ *ptdpar = 0x00; /* Configure Port TD For Digital IO */ *ddrtd = 0xE; /* Configure Port TD direction 1110 0 -> Input == TDO 1 -> Output == TDI 2 -> Output == TMS 3 -> Output == TCK */ printf("mpsInitialise: initialising rtems tick counter\n"); Timer_initialize(); /* TODO someday: put Port C back to tri-state when download done */ return OK; } int mpsFPGASetupToReadVersion() { *(short*)fpga_csar1 = 0x8000; *(short*)fpga_cscr1 = 0x00A0; *(short*)fpga_csmr1 = 0x01; return OK; } int mpsFPGAReadVersion() { printf("mpsFPGAReadVersion: lowest byte of 0x%08x\n", (unsigned int) *fpga_version); return OK; } /* Debug routine. This port is used to reprogram FPGA */ int mpsShowPortD() { printf("PortDConfig = 0x%2.2X\n",*ptdpar); printf("PortDDir = 0x%2.2X\n",*ddrtd); printf("PortD = 0x%2.2X\n",*porttd); return OK; } void WritePortD(char Value) { *porttd = Value; return ; }