From: nyatla Date: Fri, 25 Jan 2013 12:20:53 +0000 (+0000) Subject: LANドライバからFreeRTOS依存コードの取り除き X-Git-Tag: SVN-final~183 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d4c0dd69be8ab8f15571a35dc6098e241e3ad5dd;p=mimic%2FMiMicSDK.git LANドライバからFreeRTOS依存コードの取り除き git-svn-id: http://svn.osdn.jp/svnroot/mimic/trunk@188 47198e57-cb75-475f-84c4-a814cd6f29e0 --- diff --git a/lib/src/driver/uip/EtherDev_DP83848C.c b/lib/src/driver/uip/EtherDev_DP83848C.c index 2f0c2f8..b65d9d3 100644 --- a/lib/src/driver/uip/EtherDev_DP83848C.c +++ b/lib/src/driver/uip/EtherDev_DP83848C.c @@ -97,8 +97,9 @@ #define ETHDEV_PHY_DEF_ADR 0x0100 /* Default PHY device address */ - - +#ifndef configEMAC_INTERRUPT_PRIORITY + #define configEMAC_INTERRUPT_PRIORITY 5 +#endif /* Time to wait between each inspection of the link status. */ #define emacWAIT_FOR_LINK_TO_ESTABLISH_MS 500 @@ -130,11 +131,11 @@ static void prvConfigurePHY( void ); * Wait for a link to be established, then setup the PHY according to the link * parameters. */ -static long prvSetupLinkStatus( void ); +static NyLPC_TBool prvSetupLinkStatus( void ); /* * Send lValue to the lPhyReg within the PHY. */ -static long prvWritePHY( long lPhyReg, long lValue ); +static NyLPC_TBool prvWritePHY( long lPhyReg, long lValue ); /* * Read a value from ucPhyReg within the PHY. *plStatus will be set to * pdFALSE if there is an error. @@ -165,11 +166,11 @@ const static struct TiEthernetDevice _interface= * EthernetDeviceのファクトリー関数 */ -const NyLPC_TBool EthDev_DP83848C_getInterface( +NyLPC_TBool EthDev_DP83848C_getInterface( const struct TiEthernetDevice** o_dev) { unsigned long ulID1, ulID2; - long lReturn = pdPASS; + NyLPC_TBool lReturn = NyLPC_TBool_TRUE; //Reset MCU Interface. and wait for reset. prvSetupEMACHardware(); //Check peripheral name @@ -202,7 +203,7 @@ static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr) prvConfigurePHY(); //wait for Link up... - while(prvSetupLinkStatus() != pdPASS) + while(!prvSetupLinkStatus()) { NyLPC_cThread_sleep(100); } @@ -258,7 +259,8 @@ static void stop(void) static void prvSetupEMACHardware( void ) { unsigned short us; - long x, lDummy; + long x; + NyLPC_TBool lDummy; /* Power Up the EMAC controller. */ LPC_SC->PCONP |= 0x40000000; @@ -316,7 +318,7 @@ static void prvSetupEMACHardware( void ) /*-----------------------------------------------------------*/ -static long prvWritePHY( long lPhyReg, long lValue ) +static NyLPC_TBool prvWritePHY( long lPhyReg, long lValue ) { const long lMaxTime = 10; long x; @@ -338,16 +340,16 @@ static long prvWritePHY( long lPhyReg, long lValue ) if( x < lMaxTime ) { - return pdPASS; + return NyLPC_TBool_TRUE; } else { - return pdFAIL; + return NyLPC_TBool_FALSE; } } /*-----------------------------------------------------------*/ -static unsigned short prvReadPHY( unsigned int ucPhyReg, long *plStatus ) +static unsigned short prvReadPHY( unsigned int ucPhyReg, NyLPC_TBool* plStatus ) { long x; const long lMaxTime = 10; @@ -370,7 +372,7 @@ static unsigned short prvReadPHY( unsigned int ucPhyReg, long *plStatus ) if( x >= lMaxTime ) { - *plStatus = pdFAIL; + *plStatus = NyLPC_TBool_FALSE; } return( LPC_EMAC->MRDD ); @@ -391,7 +393,8 @@ static unsigned short prvReadPHY( unsigned int ucPhyReg, long *plStatus ) static void prvConfigurePHY( void ) { unsigned short us; - long x, lDummy; + long x; + NyLPC_TBool lDummy; /* Auto negotiate the configuration. */ if( prvWritePHY( PHY_REG_BMCR, PHY_AUTO_NEG ) ) @@ -412,9 +415,10 @@ static void prvConfigurePHY( void ) } } -static long prvSetupLinkStatus( void ) +static NyLPC_TBool prvSetupLinkStatus( void ) { - long lReturn = pdFAIL, x; + NyLPC_TBool lReturn = NyLPC_TBool_FALSE; + long x; unsigned short usLinkStatus; /* Wait with timeout for the link to be established. */ @@ -424,14 +428,14 @@ static long prvSetupLinkStatus( void ) if( usLinkStatus & emacLINK_ESTABLISHED ) { /* Link is established. */ - lReturn = pdPASS; + lReturn = NyLPC_TBool_TRUE; break; } NyLPC_cThread_sleep( emacWAIT_FOR_LINK_TO_ESTABLISH_MS); } - if( lReturn == pdPASS ) + if( lReturn == NyLPC_TBool_TRUE ) { /* Configure Full/Half Duplex mode. */ if( usLinkStatus & emacFULL_DUPLEX_ENABLED ) diff --git a/lib/src/driver/uip/EtherDev_DP83848C_protected.h b/lib/src/driver/uip/EtherDev_DP83848C_protected.h index e5757a0..5e1dcfb 100644 --- a/lib/src/driver/uip/EtherDev_DP83848C_protected.h +++ b/lib/src/driver/uip/EtherDev_DP83848C_protected.h @@ -12,7 +12,7 @@ extern "C" { #endif /* __cplusplus */ -const NyLPC_TBool EthDev_DP83848C_getInterface( +NyLPC_TBool EthDev_DP83848C_getInterface( const struct TiEthernetDevice** o_dev); #ifdef __cplusplus diff --git a/lib/src/driver/uip/EtherDev_LAN8720.c b/lib/src/driver/uip/EtherDev_LAN8720.c index bfd4ddf..ee32af8 100644 --- a/lib/src/driver/uip/EtherDev_LAN8720.c +++ b/lib/src/driver/uip/EtherDev_LAN8720.c @@ -88,6 +88,9 @@ #define PHY_SPEED_100 0x0008 /* 100Mbit */ #define ETHDEV_PHY_DEF_ADR 0x0100 /* Default PHY device address */ +#ifndef configEMAC_INTERRUPT_PRIORITY + #define configEMAC_INTERRUPT_PRIORITY 5 +#endif /* Time to wait between each inspection of the link status. */ #define emacWAIT_FOR_LINK_TO_ESTABLISH_MS 500 @@ -126,7 +129,7 @@ static long prvWritePHY( long lPhyReg, long lValue ); * Read a value from ucPhyReg within the PHY. *plStatus will be set to * pdFALSE if there is an error. */ -static unsigned short prvReadPHY( unsigned int ucPhyReg, long *plStatus ); +static unsigned short prvReadPHY( unsigned int ucPhyReg, NyLPC_TBool* o_status); @@ -153,16 +156,16 @@ const static struct TiEthernetDevice _interface= * EthernetDeviceのファクトリー関数。インターフェイスを生成できればtrue * */ -const NyLPC_TBool EthDev_LAN8720_getInterface( +NyLPC_TBool EthDev_LAN8720_getInterface( const struct TiEthernetDevice** o_dev) { unsigned long ulID1, ulID2; - long lReturn = pdPASS; + NyLPC_TBool ret=NyLPC_TBool_TRUE; //Reset MCU Interface. and wait for reset. prvSetupEMACHardware(); //Check peripheral name - ulID1 = prvReadPHY( PHY_REG_IDR1, &lReturn ); - ulID2 = prvReadPHY( PHY_REG_IDR2, &lReturn ); + ulID1 = prvReadPHY( PHY_REG_IDR1, &ret ); + ulID2 = prvReadPHY( PHY_REG_IDR2, &ret ); if( ( (ulID1 << 16UL ) | ( ulID2 & 0xFFF0UL ) ) != LAN8720_ID) { return NyLPC_TBool_FALSE; @@ -195,7 +198,7 @@ static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr) prvConfigurePHY(); //wait for Link up... - while(prvSetupLinkStatus() != pdPASS) + while(!prvSetupLinkStatus()) { NyLPC_cThread_sleep(100); } @@ -251,7 +254,8 @@ static void stop(void) static void prvSetupEMACHardware( void ) { unsigned short us; - long x, lDummy; + long x; + NyLPC_TBool lDummy; /* Power Up the EMAC controller. */ LPC_SC->PCONP |= 0x40000000; @@ -309,7 +313,7 @@ static void prvSetupEMACHardware( void ) /*-----------------------------------------------------------*/ -static long prvWritePHY( long lPhyReg, long lValue ) +static NyLPC_TBool prvWritePHY( long lPhyReg, long lValue ) { const long lMaxTime = 10; long x; @@ -331,16 +335,16 @@ static long prvWritePHY( long lPhyReg, long lValue ) if( x < lMaxTime ) { - return pdPASS; + return NyLPC_TBool_TRUE; } else { - return pdFAIL; + return NyLPC_TBool_FALSE; } } /*-----------------------------------------------------------*/ -static unsigned short prvReadPHY( unsigned int ucPhyReg, long *plStatus ) +static unsigned short prvReadPHY( unsigned int ucPhyReg, NyLPC_TBool *o_status) { long x; const long lMaxTime = 10; @@ -363,7 +367,7 @@ static unsigned short prvReadPHY( unsigned int ucPhyReg, long *plStatus ) if( x >= lMaxTime ) { - *plStatus = pdFAIL; + *o_status =NyLPC_TBool_FALSE; } return( LPC_EMAC->MRDD ); @@ -379,7 +383,8 @@ static unsigned short prvReadPHY( unsigned int ucPhyReg, long *plStatus ) static void prvConfigurePHY( void ) { unsigned short us; - long x, lDummy; + long x; + NyLPC_TBool lDummy; /* Auto negotiate the configuration. */ if( prvWritePHY( PHY_REG_BMCR, PHY_AUTO_NEG ) ) { @@ -399,8 +404,9 @@ static void prvConfigurePHY( void ) static long prvSetupLinkStatus( void ) { - long lReturn = pdFAIL, x; + long x; unsigned short usLinkStatus; + NyLPC_TBool lReturn=NyLPC_TBool_TRUE; /* Wait with timeout for the link to be established. */ for( x = 0; x < 10; x++ ) @@ -409,13 +415,13 @@ static long prvSetupLinkStatus( void ) if( usLinkStatus & PHY_AUTO_NEG_COMPLETE ) { /* Link is established. */ - lReturn = pdPASS; + lReturn = NyLPC_TBool_TRUE; break; } NyLPC_cThread_sleep( emacWAIT_FOR_LINK_TO_ESTABLISH_MS); } - if( lReturn == pdPASS ) + if( lReturn == NyLPC_TBool_TRUE ) { /* Configure Full/Half Duplex mode. */ if (usLinkStatus & PHY_SPEED_FDUPLX ) diff --git a/lib/src/driver/uip/EtherDev_LAN8720_protected.h b/lib/src/driver/uip/EtherDev_LAN8720_protected.h index 424cacc..d3c4835 100644 --- a/lib/src/driver/uip/EtherDev_LAN8720_protected.h +++ b/lib/src/driver/uip/EtherDev_LAN8720_protected.h @@ -11,7 +11,7 @@ extern "C" { #endif /* __cplusplus */ -const NyLPC_TBool EthDev_LAN8720_getInterface( +NyLPC_TBool EthDev_LAN8720_getInterface( const struct TiEthernetDevice** o_dev); #ifdef __cplusplus