remove MCU_CLOCK_OUT_TO_EMAC
This commit is contained in:
parent
045612298c
commit
a7ce51a606
@ -13,9 +13,9 @@
|
|||||||
#include <lwipopts.h>
|
#include <lwipopts.h>
|
||||||
|
|
||||||
/* debug option */
|
/* debug option */
|
||||||
//#define EMAC_RX_DUMP
|
#define EMAC_RX_DUMP
|
||||||
//#define EMAC_TX_DUMP
|
#define EMAC_TX_DUMP
|
||||||
//#define DRV_DEBUG
|
#define DRV_DEBUG
|
||||||
#define LOG_TAG "drv.emac"
|
#define LOG_TAG "drv.emac"
|
||||||
#include <drv_log.h>
|
#include <drv_log.h>
|
||||||
|
|
||||||
@ -76,94 +76,52 @@ static void dump_hex(const rt_uint8_t *ptr, rt_size_t buflen)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* @brief phy reset
|
// * @brief phy reset
|
||||||
*/
|
// */
|
||||||
static void phy_reset(void)
|
// static void phy_reset(void)
|
||||||
{
|
// {
|
||||||
gpio_init_type gpio_init_struct;
|
// gpio_init_type gpio_init_struct;
|
||||||
|
|
||||||
#if defined (SOC_SERIES_AT32F437)
|
// #if defined (SOC_SERIES_AT32F437)
|
||||||
crm_periph_clock_enable(CRM_GPIOE_PERIPH_CLOCK, TRUE);
|
// crm_periph_clock_enable(CRM_GPIOE_PERIPH_CLOCK, TRUE);
|
||||||
crm_periph_clock_enable(CRM_GPIOG_PERIPH_CLOCK, TRUE);
|
// crm_periph_clock_enable(CRM_GPIOG_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
gpio_default_para_init(&gpio_init_struct);
|
// gpio_default_para_init(&gpio_init_struct);
|
||||||
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
// gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
||||||
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
|
// gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
|
||||||
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
// gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
||||||
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
// gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
||||||
gpio_init_struct.gpio_pins = GPIO_PINS_15;
|
// gpio_init_struct.gpio_pins = GPIO_PINS_15;
|
||||||
gpio_init(GPIOE, &gpio_init_struct);
|
// gpio_init(GPIOE, &gpio_init_struct);
|
||||||
|
|
||||||
gpio_init_struct.gpio_pins = GPIO_PINS_15;
|
// gpio_init_struct.gpio_pins = GPIO_PINS_15;
|
||||||
gpio_init(GPIOG, &gpio_init_struct);
|
// gpio_init(GPIOG, &gpio_init_struct);
|
||||||
|
|
||||||
gpio_bits_reset(GPIOE, GPIO_PINS_15);
|
// gpio_bits_reset(GPIOE, GPIO_PINS_15);
|
||||||
gpio_bits_reset(GPIOG, GPIO_PINS_15);
|
// gpio_bits_reset(GPIOG, GPIO_PINS_15);
|
||||||
rt_thread_mdelay(2);
|
// rt_thread_mdelay(2);
|
||||||
gpio_bits_set(GPIOE, GPIO_PINS_15);
|
// gpio_bits_set(GPIOE, GPIO_PINS_15);
|
||||||
#endif
|
// #endif
|
||||||
#if defined (SOC_SERIES_AT32F407)
|
// #if defined (SOC_SERIES_AT32F407)
|
||||||
crm_periph_clock_enable(CRM_GPIOC_PERIPH_CLOCK, TRUE);
|
// crm_periph_clock_enable(CRM_GPIOC_PERIPH_CLOCK, TRUE);
|
||||||
|
|
||||||
gpio_default_para_init(&gpio_init_struct);
|
// gpio_default_para_init(&gpio_init_struct);
|
||||||
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
// gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
||||||
gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
|
// gpio_init_struct.gpio_mode = GPIO_MODE_OUTPUT;
|
||||||
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
// gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
||||||
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
// gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
||||||
gpio_init_struct.gpio_pins = GPIO_PINS_8;
|
// gpio_init_struct.gpio_pins = GPIO_PINS_8;
|
||||||
gpio_init(GPIOC, &gpio_init_struct);
|
// gpio_init(GPIOC, &gpio_init_struct);
|
||||||
|
|
||||||
gpio_bits_reset(GPIOC, GPIO_PINS_8);
|
// gpio_bits_reset(GPIOC, GPIO_PINS_8);
|
||||||
rt_thread_mdelay(2);
|
// rt_thread_mdelay(2);
|
||||||
gpio_bits_set(GPIOC, GPIO_PINS_8);
|
// gpio_bits_set(GPIOC, GPIO_PINS_8);
|
||||||
#endif
|
// #endif
|
||||||
rt_thread_mdelay(2000);
|
// rt_thread_mdelay(2000);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief phy clock config
|
|
||||||
*/
|
|
||||||
static void phy_clock_config(void)
|
|
||||||
{
|
|
||||||
#if (CRYSTAL_ON_PHY == 0)
|
|
||||||
/* if CRYSTAL_NO_PHY, output clock with pa8 of mcu */
|
|
||||||
gpio_init_type gpio_init_struct;
|
|
||||||
|
|
||||||
crm_periph_clock_enable(CRM_GPIOA_PERIPH_CLOCK, TRUE);
|
|
||||||
|
|
||||||
gpio_default_para_init(&gpio_init_struct);
|
|
||||||
gpio_init_struct.gpio_drive_strength = GPIO_DRIVE_STRENGTH_STRONGER;
|
|
||||||
gpio_init_struct.gpio_mode = GPIO_MODE_MUX;
|
|
||||||
gpio_init_struct.gpio_out_type = GPIO_OUTPUT_PUSH_PULL;
|
|
||||||
gpio_init_struct.gpio_pull = GPIO_PULL_NONE;
|
|
||||||
gpio_init_struct.gpio_pins = GPIO_PINS_8;
|
|
||||||
gpio_init(GPIOA, &gpio_init_struct);
|
|
||||||
|
|
||||||
|
|
||||||
/* 9162 clkout output 25 mhz */
|
|
||||||
/* 83848 clkout output 50 mhz */
|
|
||||||
#if defined (SOC_SERIES_AT32F407)
|
|
||||||
crm_clock_out_set(CRM_CLKOUT_SCLK);
|
|
||||||
#if (defined(PHY_USING_DM9162) || defined(PHY_USING_LAN8720A))
|
|
||||||
crm_clkout_div_set(CRM_CLKOUT_DIV_8);
|
|
||||||
#elif defined (PHY_USING_DP83848)
|
|
||||||
crm_clkout_div_set(CRM_CLKOUT_DIV_4);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (SOC_SERIES_AT32F437)
|
|
||||||
crm_clock_out1_set(CRM_CLKOUT1_PLL);
|
|
||||||
#if (defined(PHY_USING_DM9162) || defined(PHY_USING_LAN8720A))
|
|
||||||
crm_clkout_div_set(CRM_CLKOUT_INDEX_1, CRM_CLKOUT_DIV1_5, CRM_CLKOUT_DIV2_2);
|
|
||||||
#elif defined (PHY_USING_DP83848)
|
|
||||||
crm_clkout_div_set(CRM_CLKOUT_INDEX_1, CRM_CLKOUT_DIV1_5, CRM_CLKOUT_DIV2_1);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief reset phy register
|
* @brief reset phy register
|
||||||
*/
|
*/
|
||||||
@ -790,6 +748,8 @@ static void phy_monitor_thread_entry(void *parameter)
|
|||||||
#endif /* PHY_USING_INTERRUPT_MODE */
|
#endif /* PHY_USING_INTERRUPT_MODE */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern void phy_reset(void);
|
||||||
|
|
||||||
/* Register the EMAC device */
|
/* Register the EMAC device */
|
||||||
static int rt_hw_at32_emac_init(void)
|
static int rt_hw_at32_emac_init(void)
|
||||||
{
|
{
|
||||||
@ -828,8 +788,8 @@ static int rt_hw_at32_emac_init(void)
|
|||||||
goto __exit;
|
goto __exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* phy clock */
|
// /* phy clock */
|
||||||
phy_clock_config();
|
// phy_clock_config();
|
||||||
|
|
||||||
/* enable periph clock */
|
/* enable periph clock */
|
||||||
crm_periph_clock_enable(CRM_EMAC_PERIPH_CLOCK, TRUE);
|
crm_periph_clock_enable(CRM_EMAC_PERIPH_CLOCK, TRUE);
|
||||||
@ -871,6 +831,7 @@ static int rt_hw_at32_emac_init(void)
|
|||||||
|
|
||||||
/* reset phy */
|
/* reset phy */
|
||||||
phy_reset();
|
phy_reset();
|
||||||
|
rt_thread_mdelay(2000);
|
||||||
|
|
||||||
/* start phy monitor */
|
/* start phy monitor */
|
||||||
rt_thread_t tid;
|
rt_thread_t tid;
|
||||||
|
@ -16,11 +16,6 @@
|
|||||||
#include <rthw.h>
|
#include <rthw.h>
|
||||||
#include <rtthread.h>
|
#include <rtthread.h>
|
||||||
|
|
||||||
#ifdef MCU_CLOCK_OUT_TO_EMAC
|
|
||||||
#define CRYSTAL_ON_PHY 0 /* phy does not with crystal */
|
|
||||||
#else
|
|
||||||
#define CRYSTAL_ON_PHY 1
|
|
||||||
#endif
|
|
||||||
/* the phy basic control register */
|
/* the phy basic control register */
|
||||||
#define PHY_BASIC_CONTROL_REG 0x00U
|
#define PHY_BASIC_CONTROL_REG 0x00U
|
||||||
#define PHY_RESET_MASK (1 << 15)
|
#define PHY_RESET_MASK (1 << 15)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user