首页 > 编程知识 正文

如何记笔记,第四次移植的姐妹

时间:2023-05-04 06:23:35 阅读:26391 作者:1896

自行制作的f 407 ve局域网8720 a主板使用[野火] 《LwIP应用开发实战指南》系列的例行修改。 野火使用的是F407ZG的芯片,硬件布线图也不同,需要修改。

User/eth/bsp_eth.h要求更改管脚配置以匹配自己的硬件连接。

/* define eth _ mdio _ Pio _ define dfineeth _ CRS _ dv _ ping Pio _ pin _7//a7 # define eth _ CRS _ dv _ gpio _ portio define eth _ rx D1 _ gpio _ portgpioc # define eth _ tx _ en _ ping Pio _ en dfineeth _ txd0_ ping Pio _ 12//g112 管脚的GPIO_GROUP,例如define eth _ tx D1 _ ping Pio _ Pio _ piob tx D1,在相应的User/eth/bsp_eth.c文件中也是Hal _ eth _ MSP io

void Hal _ eth _ MSP init (eth _ handle typedef * eth handle ) gpio _ inittypedefgpio _ init struct; if (eth handle-instance==eth (/* usercodebegineth _ MSP init0)/* user code endeth _ MSP init0*//* enable peer///ethgpioconfigurationpc1--- eth _ mdcpa1----eth _ ref _ clk pa2---- eth _ m diopa7----eth---eth _ ttth gpio _ init struct.pull=gpio _ no pull; gpio _ init struct.speed=gpio _ speed _ freq _ very _ high; gpio _ init struct.alternate=gpio _ af11 _ eth; Hal_gpio_init(gpioc,GPIO_InitStruct; gpio _ init struct.pin=eth _ ref _ clk _ pin|eth _ mdio _ pin|eth _ CRS _ dv _ pin; gpio _ init struct.mode=gpio _ mode _ af _ PP; gpio _ init struct.pull=gpio _ no pull; gpio _ init struct.speed=gpio _ speed _ freq _ very _ high; gpio _ init struct.alternate=gpio _ af11 _ eth; Hal_gpio_init(gpioa,GPIO_InitStruct ); gio _ init struct.pin=eth _ tx _ en _ pin; gpio _ init struct.mode=gpio _ mode _ af _ PP; gpio _ init struct.pull=gpio _ no pull; gpio _ init struct.speed=gpio _ speed _ freq _ very _ high; gpio _ init struct.alternate=gpio _ af11 _ eth; Hal _ gpio _ init (eth _ tx _ en _ gpio _ port,GPIO_InitStruct ); gpio _ init struct.pin=eth _ txd0_ pin|eth _ tx D1 _ pin; gpio _ init struct.mode=gpio _ mode _ af _ PP; gpio _ init struct.pull=gpio _ no pull; gpio _ init struct.speed=gpio _ speed _ freq _ very _ high; gpio _ init struct.alternate=gpio _ af11 _ eth; Hal_gpio_init(gpiob,GPIO_InitStruct; //在此为/* usercodebegineth _ MSP init1*.//* enabletheethernetglobalinterrupt */Hal _ nvic _ set priority (eth _ Ethernet )/* enableethernetclock */_ Hal _ RCC _ eth _ clk _ enable (; /* USER CODE END ETH_MspInit 1 */}}同样,必须修改此文件下的Eth_Reset函数。 此函数在初始化开始时只进行一次硬件重置,因此根据需要进行修改。

staticvoideth _ reset {/* phy reset 3360 pi1 */gpio _ inittypedefgpio _ init structure; __HAL_RCC_GPIOC_CLK_ENABLE (; gpio _ init structure.mode=gpio _ mode _ output _ PP; gpio _ init structure.pull=gpio _ pull up; gpio _ init structure.speed=gpio _ speed _ fast; gpio _ init structure.pin=gpio _ pin _ 0; Hal_gpio_init(gpioc,GPIO_InitStructure; Hal_gpio_writepin(gpioc,GPIO_PIN_0,GPIO_PIN_RESET ); Hal_Delay(5; Hal_gpio_writepin(gpioc,GPIO_PIN_0,GPIO_PIN_SET ); Hal_Delay(5; }最后是时钟。 由于stm32使用25MHz的外部晶体振荡,因此必须在board.c的voidsystemclock_config(void )时钟配置的末尾添加MCO输出。

Hal_RCC_mcoconfig(RCC_MCO1,RCC_MCO1SOURCE_HSE,RCC_MCODIV_1); 还必须在此文件下添加管脚配置。

staticvoidMX_gpio_init(void ) gpio _ inittypedefgpio _ init struct={0};/* gpioportsclockenable *//_ Hal _ RCC _ gpioh _ clk _ enable (; __HAL_RCC_GPIOA_CLK_ENABLE (;/* configuregpiopin : pa8*/gpio _ init struct.pin=gpio _ pin _ 8; gpio _ init struct.mode=gpio _ mode _ af _ PP; gpio _ init struct.pull=gpio _ no pull; gpio _ init struct.speed=gpio _ speed _ freq _ low; gpio _ init struct.alternate=gpio _ af0 _ mco; Hal_gpio_init(gpioa,GPIO_InitStruct ); }在时钟初始化之前调用:

voidbsp_init(void ) { HAL_Init ); GPIO_CLK_Init (; MX_GPIO_Init (; 系统时钟_ config (; LED_GPIO_Config (;/* usart 1152008-n-1 */debug _ usart _ config (;/* cmbacktraceinitialize */cm _ backtrace _ init (' jiejie-f407 ',HARDWARE_VERSION,SOFTWARE_VERSION ); printf-------------- lwip demo----------------- n '; }然后下载运行就可以了~

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。

  • 相关阅读