void qspi_transmit(int data[]){ int transfer; int i; int QSPI_XMIT_RAM_BASE_ADDR = 0x00; int QSPI_CMD_RAM_BASE_ADDR = 0x20; //load data into ram // loads 8 bits at a time, 3 times for (i = 0; i < 3; i++){ MCF_QSPI_QAR = (unsigned short)(QSPI_XMIT_RAM_BASE_ADDR + i); MCF_QSPI_QDR = (unsigned short)data[i]; } //load commands into ram for (i = 0; i < 3; i++){ MCF_QSPI_QAR = QSPI_CMD_RAM_BASE_ADDR + i; MCF_QSPI_QDR = 0x4F00; } //set start and end position pointers MCF_QSPI_QWR &= MCF_QSPI_QWR_NEWQP(0); MCF_QSPI_QWR |= MCF_QSPI_QWR_ENDQP(2); //initiate transfer MCF_QSPI_QDLYR |= 0x8000; while(!(MCF_QSPI_QIR | 0x0001)){ } }
void init_qspi() { int i; // Configure initial Baud Rate to the lowest possible =833.33kbits per second // Configure number of bits per transfer to 16 MCF_QSPI_QMR = MCF_QSPI_QMR_MSTR | MCF_QSPI_QMR_BITS(0x0) | MCF_QSPI_QMR_BAUD(5); //Baud rate = system clock / 2 * baud value // Configure suitable delays for the external DAC MCF_QSPI_QDLYR = MCF_QSPI_QDLYR_QCD(0x4) | MCF_QSPI_QDLYR_DTL(0x4); // Enable wraparound mode // Use the whole 15 memory location in the transmit RAM MCF_QSPI_QWR = MCF_QSPI_QWR_WREN | MCF_QSPI_QWR_ENDQP(0x0) | MCF_QSPI_QWR_NEWQP(0x0); MCF_QSPI_QAR=0x0020; MCF_QSPI_QWR |= MCF_QSPI_QWR_CSIV; MCF_QSPI_QDR = 0x4000; // Command RAM starting Address for(i=1;i<16;i++) MCF_QSPI_QDR=0x4000; // Run QSPI MCF_QSPI_QDLYR |= MCF_QSPI_QDLYR_SPE; }