sxf_zero
sxf_zero
This guy hasn't written anything yet

注册于 10 years ago

回答
0
文章
0
关注者
0

还是没有搞定啊,帮忙看下吧
修改的文件下载附件[修改的文件.zip]

修改文件
enc28j60.c

#define CSACTIVE GPIOB->BRR = GPIO_Pin_0;
#define CSPASSIVE GPIOB->BSRR = GPIO_Pin_0;


static void RCC_Configuration(void)
{
/* enable SPI1 clock */
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

/* enable gpiob port clock */
// RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOA|RCC_APB2Periph_AFIO, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA |RCC_APB2Periph_GPIOB|RCC_APB2Periph_SPI1 | RCC_APB2Periph_AFIO, ENABLE);
}


static void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;

/* Enable the EXTI0 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}

static void GPIO_Configuration()
{
GPIO_InitTypeDef GPIO_InitStructure;
EXTI_InitTypeDef EXTI_InitStructure;

/* configure PB1 as external interrupt */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
GPIO_Init(GPIOB, &GPIO_InitStructure);

/* Configure SPI1 pins: SCK, MISO and MOSI ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);



/* Connect ENC28J60 EXTI Line to GPIOB Pin 1 */
GPIO_EXTILineConfig(GPIO_PortSourceGPIOB, GPIO_PinSource1);

/* Configure ENC28J60 EXTI Line to generate an interrupt on falling edge */
EXTI_InitStructure.EXTI_Line = EXTI_Line1;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);

/* Clear the Key Button EXTI line pending bit */
EXTI_ClearITPendingBit(EXTI_Line1);
}

static void SetupSPI (void)
{
SPI_InitTypeDef SPI_InitStructure;
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_1Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
SPI_Cmd(SPI1, ENABLE);
}


修改 stm32f10x_it.c


#if (STM32_ETH_IF == 0)
/*******************************************************************************
* Function Name : EXTI1_IRQHandler
* Description : This function handles External interrupt Line 0 request.
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void EXTI1_IRQHandler(void)
{
extern void enc28j60_isr(void);

/* enter interrupt */
rt_interrupt_enter();

enc28j60_isr();

/* Clear the Key Button EXTI line pending bit */
EXTI_ClearITPendingBit(EXTI_Line1);

/* leave interrupt */
rt_interrupt_leave();
}
#endif

引脚图[attach]627[/attach]clip_image0021.jpg

硬件应该正常,我用uip,无操作系统时,link灯不插不插网线都在有规律闪硕,有数据时数据灯不规律闪烁,数据通讯正常

\ | /
- RT - Thread Operating System
/ | \ 0.3.1 build Feb 26 2011
2006 - 2010 Copyright by rt-thread team
TCP/IP initialized!

指示灯不亮 ,ping不通,arp -a 会出现

Interface: 172.16.66.166 --- 0x10003
Internet Address Physical Address Type
172.16.66.173 00-00-00-00-00-00 invalid

enc28j60 spi1,自己尝试修改,总是不成功,郁闷,

回到
顶部

发布
问题

投诉
建议