helper2416_lwip_移植小结(转)(2)
- UID
- 1029342
- 性别
- 男
|
helper2416_lwip_移植小结(转)(2)
使能EINT15中断
配置EINT15中断模式
配置GPG7引脚EINT15功能
配置上拉下拉电阻,禁止掉因为板子有上拉电阻
LAN9220电路部分
2)LAN9220初始化
- /**
- * @brief lan9220_reset
- * @note LAN9220复位
- * @param none
- * @retval none
- */
- static void lan9220_reset(void)
- {
- int timeout;
- uint32_t reg;
- /*
- * Take out of PM setting first
- * LAN9220 ready to accessed
- */
- if ( reg_read(PMT_CTRL)&PMT_CTRL_READY ) {
- reg_write(BYTE_TEST, 0x0);
- } else {
- timeout = 10;
- while (timeout-- && !(reg_read(PMT_CTRL)&PMT_CTRL_READY)) {
- lan9220_delay(10);
- }
- if (!timeout) {
- DEBUG0(DRIVERNAME":timeout waiting for PM restore!\n");
- return ;
- }
- }
- /* 禁止中断 */
- reg_write(INT_EN, 0);
- /* 软复位,注意会清除一些寄存器 */
- reg_write(HW_CFG, HW_CFG_SRST);
- /*
- * 设置FIFO_INT接收状态等级
- * 参考寄存器说明可设置(0-255)*DWORD
- */
- reg = *(uint32_t *)FIFO_INT;
- reg |= 0x80;
- *(uint32_t *)FIFO_INT = reg;
- /* 使能并设置中断消逝时间50us */
- reg_write( INT_CFG, (1<<8)|(5<<24) );
- timeout = 1000;
- /* 检测EPC状态 */
- while ( timeout-- && reg_read(E2P_CMD)&E2P_CMD_EPC_BUSY ) {
- lan9220_delay(10);
- }
- if ( !timeout ) {
- DEBUG0(DRIVERNAME": EPC is busy!\n");
- return ;
- }
- reg = reg_read(INT_EN);
- /* 设置软件SW_INT_EN中断 */
- reg |= 0x80000000;
- reg_write(INT_EN, reg);
- /* 设置接收状态---FIFO-LEVEL中断 */
- reg |= 0x00000008;
- reg_write(INT_EN, reg);
- /* 复位FIFO等级和流控设置 */
- lan9220_set_mac_csr(FLOW, FLOW_FCPT|FLOW_FCEN);
- reg_write(AFC_CFG, 0x0050287F);
- /* 设置LED输出 */
- reg_write(GPIO_CFG, 0x70070000);
- }
复制代码 |
|
|
|
|
|