你好,我使用的OMAPL138在进行网口测试时,网口不能初始化
#include "stdio.h"
#include "string.h"
#include "types.h"
#include "evmomapl138.h"
#include "evmomapl138_timer.h"
#include "ethernet_smsc.h"
#include "evmomapl138_emac.h"
#include "evmomapl138_gpio.h"
#include "evmomapl138_i2c_gpio.h"
#include "evmomapl138_cdce913.h"
//—————————————————————————–
// Private Defines and Macros
//—————————————————————————–
// mdio clock divide down value.
#define MDIO_CLK_FREQ_HZ (2000000)
#define MDIO_CLK_DIVISOR ((SYSCLOCK4_HZ / MDIO_CLK_FREQ_HZ) – 1)
// packet defines.
#define MAX_RX_BUFFERS (10)
#define MIN_PACKET_SIZE (46)
#define MAX_PACKET_SIZE (1518)
#define PACKET_ALIGN (18)
// rx / tx desriptor memory offsets.
#define RX_DESC_OFFSET (0)
#define TX_DESC_OFFSET (0x1000)
//MII pinmux
#define PINMUX_MII_REG_0 (2)
#define PINMUX_MII_MASK_0 (0xFFFFFFF0)
#define PINMUX_MII_VAL_0 (0x88888880)
#define PINMUX_MII_REG_1 (3)
#define PINMUX_MII_MASK_1 (0xFFFFFFFF)
#define PINMUX_MII_VAL_1 (0x88888888)
//RMII pinmux
#define PINMUX_RMII_REG_0 (14)
#define PINMUX_RMII_MASK_0 (0xFFFFFF00)
#define PINMUX_RMII_VAL_0 (0x88888800)
#define PINMUX_RMII_REG_1 (15)
#define PINMUX_RMII_MASK_1 (0x000000FF)
#define PINMUX_RMII_VAL_1 (0x00000080)
//MDIO pinmux
#define PINMUX_MDIO_REG (4)
#define PINMUX_MDIO_MASK (0x000000FF)
#define PINMUX_MDIO_VAL (0x00000088)
//GPIO pinmux
#define PINMUX_MII_MDIO_EN_REG (6)
#define PINMUX_MII_MDIO_EN_MASK (0x000000F0)
#define PINMUX_MII_MDIO_EN_VAL (0x00000080)
//
#define EMAC_RMII_SPEED_100(0x00008000)
//—————————————————————————–
// Private Static Variables
//—————————————————————————–
static uint8_t g_active_phy_id = 0xFF;
static volatile emac_descriptor_t *g_rx_desc = (emac_descriptor_t *)(EMAC_RAM_BASE + RX_DESC_OFFSET);
static volatile emac_descriptor_t *g_tx_desc = (emac_descriptor_t *)(EMAC_RAM_BASE + TX_DESC_OFFSET);
static volatile emac_descriptor_t *g_rx_active_head = 0;
static volatile emac_descriptor_t *g_rx_active_tail = 0;
static uint8_t g_rx_queue_active = 0;
static uint8_t g_rx_buffers[MAX_RX_BUFFERS * (MAX_PACKET_SIZE + PACKET_ALIGN)];
//—————————————————————————–
// Private Function Prototypes
//—————————————————————————–
static uint32_t initMdioPhy(void);
static uint8_t isLinkActive(uint8_t in_phy);
static uint16_t phyRegRead(uint8_t in_phy, uint8_t in_reg);
static void phyRegWrite(uint8_t in_phy, uint8_t in_reg, uint16_t in_data);
//—————————————————————————–
// Public Function Definitions
//—————————————————————————–
//—————————————————————————–
// \brief initialize the EMAC and MDIO for use.
//
// \param none.
//
// \return uint32_t
// ERR_NO_ERROR – everything is ok…emac ready to use.
// ERR_INIT_FAIL – something happened during initialization.
//—————————————————————————–
uint32_t EMAC_init(emac_interface_e emac_interface)
{
uint32_t rtn = 0;
uint32_t i;
volatile emac_descriptor_t *tmp_rx_desc;
// reset emac module.
EMAC->SOFTRESET = 1;
while (EMAC->SOFTRESET != 0) {}
到这一句程序一直等待,寄存器SOFTRESET显示是0,不能读1,不知道是哪里的问题?能否说明给出解决的方法,谢谢,使用的是CCS4
yi xu:
回复 noaming:
用的就是这个例程里面的DSP eXp Emac Loopback MII Test这个测试,主函数里对timer和I2C进行了初始化, USTIMER_init();
I2C_init(I2C0, I2C_CLK_400K);
// TEST EMAC, MDIO
//—————-
results += TEST_mii_loopback();
然后调用了TEST_mii_loopback,在其中对网口初始化的时候出现了上面的问题
yi xu:
回复 noaming:
用的就是这个例程里面的DSP eXp Emac Loopback MII Test这个测试,主函数里对timer和I2C进行了初始化, USTIMER_init();
I2C_init(I2C0, I2C_CLK_400K);
// TEST EMAC, MDIO
//—————-
results += TEST_mii_loopback();
然后调用了TEST_mii_loopback,在其中对网口初始化的时候出现了上面的问题
yi xu:
回复 yi xu:
我在I2C的初始化下面加了一个芯片的初始化 问题解决了
USTIMER_init();
I2C_init(I2C0, I2C_CLK_400K);
EVMOMAPL138_init();
非常感谢
noaming:
回复 yi xu:
恩,不必客气,有问题再探讨。