-
如何赚一块能玩游戏的开发板? https://bbs.eeworld.com.cn/thread-1193598-1-1.html
-
m0价格便宜,新唐mini51才0.5个美金左右。使用方便,编程基本不用管寄存器。完整的库,入门不错的选择。
-
川北兄,真给力,学习了。。
-
川北兄,搞得不错的嘛。来给你混混。。。
-
文章里给了下载方式和地址的哈
-
what?
-
兄弟不妨用proteus仿块mini2440和大家分享一下,也正好解决qemu不能看到led的缺陷,我对proteus不熟悉,正好也可能给你学习学习
-
差别肯定是有的,注要在于驱动那里,有的看不到现象罢了,自己注意点用,没什么的
-
最近工作有点忙,很少过来,这不一有好东东,就来了
-
分享创意前两天把以前写的整理了一下,放在这里网络开发笔记(完整)
[ 本帖最后由 yuhua8688 于 2011-1-5 13:27 编辑 ]
-
1.lm3s的固件库没stm32的使用方便。我在用stm32时不用去背一个函数及其参数。只要打开*.h头文件,在函数
名的形参上用 ctrl+F就可以找到可用的实参,而lm3s不行,希望这点改进一下。
2.cortex M3有强大的资源,但一点多加不上“强大”的操作系统,这里是指Linux,主要是多数没留出外总线,
支持不了大Flash,而实际有些应用想要Linux的应用方案,只记得stm32官方有一个uCLinux的解决方案,希望
TI也能给一个解决方案。
3.现在在公司,老总一直强调,芯片的保密性,防盗版能力,在这一点很少看到,LM3S对Flash的加密资料,希望
TI能在这方面做得更好。
总的来说Lm3s是很好用的,配置简单,易学易用。
在此也希望,论坛越办越好
-
rlarm.chm帮助
-
最大连接数可以在net_config.c,的HTTP下边配置,我没发现死机的情况,至于内存多少,这还没研究过
-
网上下个RL-ARM包,装一下,最好和keil装在一起,里面就有
-
/*--------------------------- write_PHY -------------------------------------*/
static void write_PHY (U32 PhyReg, U16 Value) {
/* Write a data 'Value' to PHY register 'PhyReg'. */
U32 tout;
pEMAC->MADR = PHY_DEF_ADR;
pEMAC->MTXD = Value;
pEMAC->MCTL = (PhyReg << 3) | MCTL_WR | MCTL_START;
/* Wait util operation completed */
for (tout = 0; tout < MII_WR_TOUT; tout++) {
if ((pEMAC->MCTL & MCTL_START) == 0) {
break;
}
}
}
/*--------------------------- read_PHY --------------------------------------*/
static U16 read_PHY (U32 PhyReg) {
/* Read a PHY register 'PhyReg'. */
U32 tout;
pEMAC->MADR = PHY_DEF_ADR;
pEMAC->MCTL = (PhyReg << 3) | MCTL_START;
/* Wait until operation completed */
for (tout = 0; tout < MII_RD_TOUT; tout++) {
if ((pEMAC->MCTL & MCTL_START) == 0) {
break;
}
}
return (pEMAC->MRXD & MRXD_MASK);
}
/*----------------------------------------------------------------------------
* end of file
*---------------------------------------------------------------------------*/
我觉得这里讲得太细的话,我可能会花几天,写几篇文章,但是还是讲不清楚
所以我只注识了一下,我认为比较重要的地方,希望帮助理解
移植也就是重写这里的几个函数。别的应用程序都一样
-
/* Start Transmitting */
pEMAC->TXRQ = TXRQ_NEW_TX;
}
/*--------------------------- interrupt_ethernet ----------------------------*/
void interrupt_ethernet (void) __irq {//中断处理函数
/* EMAC Ethernet Controller Interrupt function. */
OS_FRAME *frame;
U32 val,int_stat,RxLen,len;
U16 *dp;
while ((int_stat = pEMAC->ISR & INT_ALL) != 0) {
pEMAC->ISR = int_stat;
if (int_stat & INT_RX) {
/* Packet received, get the packet size. */
//接收包
val = pEMAC->DATA;
RxLen = (val & 0xFFFF) - 6;
/* DMA adds also 4-byte CRC and 2-byte 'size' to packet size. */
if (RxLen > ETH_MTU || (int_stat & INT_RX_ERR)) {
/* Invalid frame, ignore it and free buffer. */
goto rel;
}
/* Flag 0x80000000 to skip sys_error() call when out of memory. */
frame = alloc_mem (RxLen | 0x80000000);
if (frame != NULL) {
dp = (U16 *)&frame->data[0];
for (len = (RxLen + 3) >> 2; len; dp += 2, len--) {
dp[0] = val >> 16;
val = pEMAC->DATA;
dp[1] = val & 0xFFFF;
}
if ((RxLen - 1) & 0x02) {
/* Drain the remaining 1 or 2 byte(s) of the CRC. */
val = pEMAC->DATA;
}
put_in_queue (frame);
}
else {
/* In case of error discard the entire RX FIFO. */
rel: pEMAC->RXCTL &= ~RXCTL_RX_EN;
pEMAC->RXCTL |= RXCTL_RST_FIFO;
pEMAC->RXCTL |= RXCTL_RX_EN;
}
}
}
}
-
/*--------------------------- int_enable_eth --------------------------------*/
void int_enable_eth (void) {//使能中断
/* Ethernet Interrupt Enable function. */
IntEnable(INT_ETH);
}
/*--------------------------- int_disable_eth -------------------------------*/
void int_disable_eth (void) {//禁止中断
/* Ethernet Interrupt Disable function. */
IntDisable(INT_ETH);
}
/*--------------------------- send_frame ------------------------------------*/
void send_frame (OS_FRAME *frame) {//发送数据
/* Send frame to EMAC ethernet controller */
U32 len,val;
U16 *sp;
/* Wait for current packet to complete. */
while (pEMAC->TXRQ & TXRQ_NEW_TX);
sp = (U16 *)&frame->data[0];
val = frame->length - 14;
val |= (*sp++) << 16;
pEMAC->DATA = val;
/* Copy frame data to EMAC packet buffers. */
for (len = (frame->length + 1) >> 2; len; sp += 2, len--) {
pEMAC->DATA = sp[0] | ((U32)sp[1] << 16);
}
-
#if defined (_10MBIT_)//10M模式
/* Connect at 10MBit */
write_PHY (PHY_REG_CTRL, PHY_FULLD_10M);
#elif defined (_100MBIT_)//100M模式
/* Connect at 100MBit */
write_PHY (PHY_REG_CTRL, PHY_FULLD_100M);
#else
/* Use autonegotiation about the link speed. */
write_PHY (PHY_REG_CTRL, PHY_AUTO_NEG);
/* Wait to complete Auto_Negotiation. */
for (tout = 0; tout < 0x20000; tout++) {
regv = read_PHY (PHY_REG_STAT);
if (regv & 0x0020) {
/* Autonegotiation Complete. */
break;
}
}
#endif
/* Check the link status. */
for (tout = 0; tout < 0x10000; tout++) {
regv = read_PHY (PHY_REG_STAT);
if (regv & 0x0004) {
/* Link is on. */
break;
}
}
/* Configure TX/RX Control Registers, enable Multicast. */
pEMAC->RXCTL = RXCTL_BAD_CRC | RXCTL_RST_FIFO | RXCTL_MCAST_EN;
pEMAC->TXCTL = TXCTL_PAD_EN | TXCTL_CRC_EN;
/* Configure Full/Half Duplex mode. */
if (regv & 0x0800) {
/* Full duplex is enabled. */
pEMAC->TXCTL |= TXCTL_DUP_EN;
}
/* Set the Ethernet MAC Address registers */
pEMAC->IAR0 = ((U32)own_hw_adr[3] << 24) | ((U32)own_hw_adr[2] << 16) |
((U32)own_hw_adr[1] << 8) | (U32)own_hw_adr[0];
pEMAC->IAR1 = ((U32)own_hw_adr[5] << 8) | (U32)own_hw_adr[4];
/* Enable the Ethernet Controller */
pEMAC->RXCTL |= RXCTL_RX_EN;
pEMAC->TXCTL |= TXCTL_TX_EN;
/* Enable Interrupts */
pEMAC->IEN = INT_RX;
IntEnable(INT_ETH);//使能网络控制器
}
-
/*--------------------------- init_ethernet ---------------------------------*/
void init_ethernet (void) {//初始化网络控制器
/* Initialize the EMAC ethernet controller. */
U32 tout,regv;
/* Enable and Reset the Ethernet Controller */
//使能网络控制器时钟
SysCtlPeripheralEnable (SYSCTL_PERIPH_ETH);
SysCtlPeripheralReset (SYSCTL_PERIPH_ETH);
/* Enable Port F for Ethernet LEDs */
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF);
GPIODirModeSet (GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3),
GPIO_DIR_MODE_HW);
GPIOPadConfigSet(GPIO_PORTF_BASE, (GPIO_PIN_2 | GPIO_PIN_3),
GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD);
/* Disable all Ethernet Interrupts */
//禁止中断
pEMAC->IEN = 0;
pEMAC->ISR = INT_ALL;
/* Set MII interface clock (max. 2.5MHz) */
pEMAC->MCDIV = 10;
/* Put the PHY in reset mode */
write_PHY (PHY_REG_CTRL, 0x8000);
/* Wait for hardware reset to end. */
for (tout = 0; tout < 0x20000; tout++) {
regv = read_PHY (PHY_REG_CTRL);
if (!(regv & 0x8000)) {
/* Reset complete. */
break;
}
}
-
*----------------------------------------------------------------------------
* Name: LM3S_EMAC.C
* Purpose: Driver for Luminary Micro LM3Sxxxx EMAC Ethernet Controller
* Rev.: V4.05
*----------------------------------------------------------------------------
* This code is part of the RealView Run-Time Library.
* Copyright (c) 2004-2009 KEIL - An ARM Company. All rights reserved.
*---------------------------------------------------------------------------*/
#include <Net_Config.h>
#include <LM3Sxxxx.H>
#include "LM3S_EMAC.h"
/* The following macro definitions may be used to select the speed
of the physical link:
_10MBIT_ - connect at 10 MBit only
_100MBIT_ - connect at 100 MBit only
By default an autonegotiation of the link speed is used. This may take
longer to connect, but it works for 10MBit and 100MBit physical links. */
/* Net_Config.c */
extern U8 own_hw_adr[];
/*----------------------------------------------------------------------------
* EMAC Ethernet Driver Functions
*----------------------------------------------------------------------------
* Required functions for Ethernet driver module:
* 这里是轮询的方法
* a. Polling mode: - void init_ethernet ()
* - void send_frame (OS_FRAME *frame)
* - void poll_ethernet (void)
* 这里是中断的方法
* b. Interrupt mode: - void init_ethernet ()
* - void send_frame (OS_FRAME *frame)
* - void int_enable_eth ()
* - void int_disable_eth ()
* - interrupt function
*---------------------------------------------------------------------------*/
/* Local Function Prototypes */
static void write_PHY (U32 PhyReg, U16 Value);//写寄存器
static U16 read_PHY (U32 PhyReg);//读寄存器