📄 net_bsp.c
字号:
/*
*********************************************************************************************************
* uC/TCP-IP
* The Embedded TCP/IP Stack
*
* (c) Copyright 2004; Micrium, Inc.; Weston, FL
*
* All rights reserved. Protected by international copyright laws.
* Knowledge of the source code may not be used to write a similar
* product. This file may only be used in accordance with a license
* and should not be redistributed in any way.
*********************************************************************************************************
*
* BOARD SUPPORT PACKAGE (BSP) FUNCTIONS
*
* Freescale i.MX21
*
* Filename : net_bsp.c
* Programmer : Eric Shufro
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* INCLUDE FILES
*********************************************************************************************************
*/
#include <includes.h>
#include <net_nic.h>
/*
*********************************************************************************************************
* LOCAL DEFINES
*********************************************************************************************************
*/
#define CS8900ABaseAddress (*((INT16U *)0xCC000000)) /* 16 bytes long */
#define INT_ARM_PortE 8 /* ARM IRQ 8 is internally mapped to GPIO Interrupts */
#define INT_GPIO_Pin_Mask (1 << 11) /* GPIO Port E, pin 11 is attached to the cs8900 INTRQ pin */
#define PortE_Edge_Sel (1 << 23) /* Set pin 11 to high level sensitive. Bits 23:22 = 1:0 */
/*
*********************************************************************************************************
* PROTOTYPES
*********************************************************************************************************
*/
extern void NetNIC_ISR_Handler(void);
/*$PAGE*/
/*
*********************************************************************************************************
*********************************************************************************************************
* NETWORK INTERFACE CARD FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/
/*
*********************************************************************************************************
* NETWORK INTERRUPT INITIALIZATION
*
* Description : This function is called by CS8900_Init() to to initialize the interrupt structure for the NIC.
*
* Arguments : none
*
* Note(s) : 1) The CS8900A is connected to external interrupt #4 on the LogicPD board because it
* passes through the I/O board.
*********************************************************************************************************
*/
void NetNIC_IntInit (void)
{
BSP_Set_IRQ_Vector(INT_ARM_PortE, NetNIC_ISR_Handler); /* Insert the CS8900A ISR Handler into the interrupt table */
BSP_IntEn(INT_ARM_PortE); /* Enable GPIO Port E interrupts */
PTE_ICR1 = PortE_Edge_Sel; /* Set port E pin 11 interrupt to trigger on high level */
PTE_IMR = INT_GPIO_Pin_Mask; /* Unmask Port E, pin 11 interrupts */
}
/*
*********************************************************************************************************
* INITIALIZE INTERRUPT CONTROLLER
*
* Description : This function is called to clear the interrupt controller associated with the NIC.
*
* Arguments : none
*********************************************************************************************************
*/
void NetNIC_IntClr (void)
{
PTE_ISR |= INT_GPIO_Pin_Mask; /* Clear the port E, pin 11 interrupt flag */
}
/*$PAGE*/
/*
*********************************************************************************************************
* NetNIC_Rd16()
*
* Description : Read 16-bit data value from the Ethernet chip.
*
* Argument(s) : reg_offset Register address offset.
*
* Return(s) : 16-bit data read from register.
*
* Caller(s) : CS8900A_RegRd().
*
* Notes(s) : 1) You need to know the actual physical address or location of the NIC. From that, you
* simply add the offset passed to this function to this 'base' address.
*********************************************************************************************************
*/
CPU_INT16U NetNIC_Rd16 (CPU_INT16U reg_offset)
{
INT16U *CS8900Addr;
CS8900Addr = &CS8900ABaseAddress; /* Set a pointer to the CS8900 Base Address */
return CS8900Addr[reg_offset/2]; /* Get the data from the specified offset */
/* Offset / 2 to make the offset type (8 bit) the same as */
/* the register type (16 bit) */
}
/*
*********************************************************************************************************
* NetNIC_Wr16()
*
* Description : Write 16-bit data value to the NIC
*
* Argument(s) : reg_offset Register address offset.
*
* val 16-bit data to write to register.
*
* Return(s) : none.
*
* Caller(s) : CS8900A_RegRd(),
* CS8900A_RegWr().
*
* Notes(s) : 1) You need to know the actual physical address or location of the NIC. From that, you
* simply add the offset passed to this function to this 'base' address.
*********************************************************************************************************
*/
void NetNIC_Wr16 (CPU_INT16U reg_offset, CPU_INT16U val)
{
INT16U *targetRegister;
targetRegister = &CS8900ABaseAddress; /* declare a pointer to the cs8900 base address */
targetRegister[reg_offset/2] = val; /* Write the value to the register */
/* Offset / 2 to make the offset type (8 bit) the same as */
/* the register type (16 bit) */
}
/*$PAGE*/
/*
*********************************************************************************************************
* CS8900A_PwrCtrl()
*
* Description : Control power to the CS8900A, if supported by your application's hardware. This feature
* would be provided if power consumption is an issue in your application.
*
* Argument(s) : pwr Control power to the CS8900A :
*
* NET_ON Apply power to the CS8900A
* NET_OFF Remove power from the CS8900A
*
* Return(s) : none.
*
* Caller(s) : none.
*
* Note(s) : Not supported on the Freescale i.MX21ADS
*********************************************************************************************************
*/
void CS8900A_PwrCtrl (CPU_BOOLEAN pwr)
{
}
/*
*********************************************************************************************************
* CS8900A_Reset_Delay()
*
* Description : Delays the CS8900 initialization task for approximately 10 or more ms while the
* CS8900 stabilizes after reset.
*
* Argument(s) : None
*
* Return(s) : none.
*
* Caller(s) : net_nic.c
*
* Notes : This functiond does not require the presence of an OS. Spinning a loop for
* : 10ms or more will suffice.
*********************************************************************************************************
*/
void NET_BSP_CS8900A_Reset_Delay (void)
{
OSTimeDlyHMSM(0,0,0,20); /* Delay 20ms while the CS8900 resets */
}
/*$PAGE*/
/*
*********************************************************************************************************
*********************************************************************************************************
* NETWORK MODULE FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -