登录后继续查看
登录注册
登录后继续评论
spi spi_open_device(unsigned int device) { int status; u16 dev_id; unsigned int base_address; u32 control; if (device < XPAR_XSPI_NUM_INSTANCES) { dev_id = (u16) device; } else { int found = 0; for (u16 i = 0; i < XPAR_XSPI_NUM_INSTANCES; ++i) { if (XSpi_ConfigTable[i].BaseAddress == device) { found = 1; dev_id = i; break; } } if (!found) return -1; } status = XSpi_Initialize(&xspi[dev_id], dev_id); if (status != XST_SUCCESS) { return -1; } base_address = xspi[dev_id].BaseAddr; // Soft reset SPI XSpi_WriteReg(base_address, XSP_SRR_OFFSET, 0xA); // Master mode control = XSpi_ReadReg(base_address, XSP_CR_OFFSET); // Master Mode control |= XSP_CR_MASTER_MODE_MASK; // Enable SPI control |= XSP_CR_ENABLE_MASK; // Slave select manually control |= XSP_INTR_SLAVE_MODE_MASK; // Enable Transmitter control &= ~XSP_CR_TRANS_INHIBIT_MASK; // Write configuration word XSpi_WriteReg(base_address, XSP_CR_OFFSET, control); return (spi) dev_id; }
ChipDebug入站需知
本站无广告也无付费项目,如发现帐号发垃圾帖或评论的一律封号!
ChipDebug是一个芯片开发调试分享网站 欢迎您的到来!如果您没有帐户请先点击下方按钮进行注册