2 FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.
\r
4 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
5 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
10 * Complete, revised, and edited pdf reference manuals are also *
\r
13 * Purchasing FreeRTOS documentation will not only help you, by *
\r
14 * ensuring you get running as quickly as possible and with an *
\r
15 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
16 * the FreeRTOS project to continue with its mission of providing *
\r
17 * professional grade, cross platform, de facto standard solutions *
\r
18 * for microcontrollers - completely free of charge! *
\r
20 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
22 * Thank you for using FreeRTOS, and thank you for your support! *
\r
24 ***************************************************************************
\r
27 This file is part of the FreeRTOS distribution.
\r
29 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
30 the terms of the GNU General Public License (version 2) as published by the
\r
31 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
32 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
33 distribute a combined work that includes FreeRTOS without being obliged to
\r
34 provide the source code for proprietary components outside of the FreeRTOS
\r
35 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
36 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
37 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
38 more details. You should have received a copy of the GNU General Public
\r
39 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
40 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
41 by writing to Richard Barry, contact details for whom are available on the
\r
46 ***************************************************************************
\r
48 * Having a problem? Start by reading the FAQ "My application does *
\r
49 * not run, what could be wrong?" *
\r
51 * http://www.FreeRTOS.org/FAQHelp.html *
\r
53 ***************************************************************************
\r
56 http://www.FreeRTOS.org - Documentation, training, latest versions, license
\r
57 and contact details.
\r
59 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
60 including FreeRTOS+Trace - an indispensable productivity tool.
\r
62 Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell
\r
63 the code with commercial support, indemnification, and middleware, under
\r
64 the OpenRTOS brand: http://www.OpenRTOS.com. High Integrity Systems also
\r
65 provide a safety engineered and independently SIL3 certified version under
\r
66 the SafeRTOS brand: http://www.SafeRTOS.com.
\r
69 /* FreeRTOS includes. */
\r
70 #include "FreeRTOS.h"
\r
75 /* Library includes. */
\r
76 #include "stm32fxxx_eth.h"
\r
77 #include "stm32f10x_gpio.h"
\r
78 #include "stm32f10x_rcc.h"
\r
79 #include "stm32f10x_nvic.h"
\r
81 /*-----------------------------------------------------------*/
\r
83 /* Hardware specifics. */
\r
84 #define uipRCC_MAC_CLOCK ( 1UL << 14UL )
\r
85 #define uipRCC_MAC_TX_CLOCK ( 1UL << 15UL )
\r
86 #define uipRCC_MAC_RX_CLOCK ( 1UL << 16UL )
\r
87 #define uipPHY_ADDRESS ( 1 )
\r
88 #define uipENET_IRQ_NUM ( 61 )
\r
89 #define uipMODE_MII ( 1UL << 23UL )
\r
90 #define uipREMAP_MAC_IO ( 1UL << 21UL )
\r
92 /* The number of descriptors to chain together for use by the Rx DMA. */
\r
93 #define uipNUM_RX_DESCRIPTORS 4
\r
95 /* The total number of buffers to be available. At most (?) there should be
\r
96 one available for each Rx descriptor, one for current use, and one that is
\r
97 in the process of being transmitted. */
\r
98 #define uipNUM_BUFFERS ( uipNUM_RX_DESCRIPTORS + 2 )
\r
100 /* Each buffer is sized to fit an entire Ethernet packet. This is for
\r
101 simplicity and speed, but could waste RAM. */
\r
102 #define uipMAX_PACKET_SIZE 1520
\r
104 /* The field in the descriptor that is unused by this configuration is used to
\r
105 hold the send count. This is just #defined to a meaningful name. */
\r
106 #define SendCount Buffer2NextDescAddr
\r
108 /* If no buffers are available, then wait this long before looking again.... */
\r
109 #define uipBUFFER_WAIT_DELAY ( 3 / portTICK_RATE_MS )
\r
111 /* ...and don't look more than this many times. */
\r
112 #define uipBUFFER_WAIT_ATTEMPTS ( 30 )
\r
114 /* Let the DMA know that a new descriptor has been made available to it. */
\r
115 #define prvRxDescriptorAvailable() ETH_DMA->DMARPDR = 0
\r
117 /*-----------------------------------------------------------*/
\r
120 * Configure the IO for Ethernet use.
\r
122 static void prvSetupEthGPIO( void );
\r
125 * Return a pointer to an unused buffer, marking the returned buffer as now
\r
128 static unsigned char *prvGetNextBuffer( void );
\r
130 /*-----------------------------------------------------------*/
\r
132 /* Allocate the Rx descriptors used by the DMA. */
\r
133 static ETH_DMADESCTypeDef xRxDescriptors[ uipNUM_RX_DESCRIPTORS ] __attribute__((aligned(4)));
\r
135 /* Allocate the descriptor used for transmitting. It might be that better
\r
136 performance could be achieved by having more than one Tx descriptor, but
\r
137 in this simple case only one is used. */
\r
138 static volatile ETH_DMADESCTypeDef xTxDescriptor __attribute__((aligned(4)));
\r
140 /* Buffers used for receiving and transmitting data. */
\r
141 static unsigned char ucMACBuffers[ uipNUM_BUFFERS ][ uipMAX_PACKET_SIZE ] __attribute__((aligned(4)));
\r
143 /* Each ucBufferInUse index corresponds to a position in the same index in the
\r
144 ucMACBuffers array. If the index contains a 1 then the buffer within
\r
145 ucMACBuffers is in use, if it contains a 0 then the buffer is free. */
\r
146 static unsigned char ucBufferInUse[ uipNUM_BUFFERS ] = { 0 };
\r
148 /* Index to the Rx descriptor to inspect next when looking for a received
\r
150 static unsigned long ulNextDescriptor;
\r
152 /* The uip_buffer is not a fixed array, but instead gets pointed to the buffers
\r
153 allocated within this file. */
\r
154 extern unsigned char * uip_buf;
\r
156 /*-----------------------------------------------------------*/
\r
158 portBASE_TYPE xEthInitialise( void )
\r
160 static ETH_InitTypeDef xEthInit; /* Static so as not to take up too much stack space. */
\r
161 NVIC_InitTypeDef xNVICInit;
\r
162 const unsigned char ucMACAddress[] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
\r
163 portBASE_TYPE xReturn;
\r
166 /* Start with things in a safe known state. */
\r
168 for( ul = 0; ul < uipNUM_RX_DESCRIPTORS; ul++ )
\r
170 ETH_DMARxDescReceiveITConfig( &( xRxDescriptors[ ul ] ), DISABLE );
\r
173 /* Route clock to the peripheral. */
\r
174 RCC->AHBENR |= ( uipRCC_MAC_CLOCK | uipRCC_MAC_TX_CLOCK | uipRCC_MAC_RX_CLOCK );
\r
176 /* Set the MAC address. */
\r
177 ETH_MACAddressConfig( ETH_MAC_Address0, ( unsigned char * ) ucMACAddress );
\r
179 /* Use MII mode. */
\r
180 AFIO->MAPR &= ~( uipMODE_MII );
\r
182 /* Configure all the GPIO as required for MAC/PHY interfacing. */
\r
185 /* Reset the peripheral. */
\r
186 ETH_SoftwareReset();
\r
187 while( ETH_GetSoftwareResetStatus() == SET );
\r
189 /* Initialise using the whopping big structure. Code space could be saved
\r
190 by making this a const struct, however that would mean changes to the
\r
191 structure within the library header files could break the code, so for now
\r
192 just set everything manually at run time. */
\r
193 xEthInit.ETH_AutoNegotiation = ETH_AutoNegotiation_Enable;
\r
194 xEthInit.ETH_Watchdog = ETH_Watchdog_Disable;
\r
195 xEthInit.ETH_Jabber = ETH_Jabber_Disable;
\r
196 xEthInit.ETH_JumboFrame = ETH_JumboFrame_Disable;
\r
197 xEthInit.ETH_InterFrameGap = ETH_InterFrameGap_96Bit;
\r
198 xEthInit.ETH_CarrierSense = ETH_CarrierSense_Enable;
\r
199 xEthInit.ETH_Speed = ETH_Speed_10M;
\r
200 xEthInit.ETH_ReceiveOwn = ETH_ReceiveOwn_Disable;
\r
201 xEthInit.ETH_LoopbackMode = ETH_LoopbackMode_Disable;
\r
202 xEthInit.ETH_Mode = ETH_Mode_HalfDuplex;
\r
203 xEthInit.ETH_ChecksumOffload = ETH_ChecksumOffload_Disable;
\r
204 xEthInit.ETH_RetryTransmission = ETH_RetryTransmission_Disable;
\r
205 xEthInit.ETH_AutomaticPadCRCStrip = ETH_AutomaticPadCRCStrip_Disable;
\r
206 xEthInit.ETH_BackOffLimit = ETH_BackOffLimit_10;
\r
207 xEthInit.ETH_DeferralCheck = ETH_DeferralCheck_Disable;
\r
208 xEthInit.ETH_ReceiveAll = ETH_ReceiveAll_Enable;
\r
209 xEthInit.ETH_SourceAddrFilter = ETH_SourceAddrFilter_Disable;
\r
210 xEthInit.ETH_PassControlFrames = ETH_PassControlFrames_ForwardPassedAddrFilter;
\r
211 xEthInit.ETH_BroadcastFramesReception = ETH_BroadcastFramesReception_Disable;
\r
212 xEthInit.ETH_DestinationAddrFilter = ETH_DestinationAddrFilter_Normal;
\r
213 xEthInit.ETH_PromiscuousMode = ETH_PromiscuousMode_Disable;
\r
214 xEthInit.ETH_MulticastFramesFilter = ETH_MulticastFramesFilter_Perfect;
\r
215 xEthInit.ETH_UnicastFramesFilter = ETH_UnicastFramesFilter_Perfect;
\r
216 xEthInit.ETH_HashTableHigh = 0x0;
\r
217 xEthInit.ETH_HashTableLow = 0x0;
\r
218 xEthInit.ETH_PauseTime = 0x0;
\r
219 xEthInit.ETH_ZeroQuantaPause = ETH_ZeroQuantaPause_Disable;
\r
220 xEthInit.ETH_PauseLowThreshold = ETH_PauseLowThreshold_Minus4;
\r
221 xEthInit.ETH_UnicastPauseFrameDetect = ETH_UnicastPauseFrameDetect_Disable;
\r
222 xEthInit.ETH_ReceiveFlowControl = ETH_ReceiveFlowControl_Disable;
\r
223 xEthInit.ETH_TransmitFlowControl = ETH_TransmitFlowControl_Disable;
\r
224 xEthInit.ETH_VLANTagComparison = ETH_VLANTagComparison_16Bit;
\r
225 xEthInit.ETH_VLANTagIdentifier = 0x0;
\r
226 xEthInit.ETH_DropTCPIPChecksumErrorFrame = ETH_DropTCPIPChecksumErrorFrame_Disable;
\r
227 xEthInit.ETH_ReceiveStoreForward = ETH_ReceiveStoreForward_Enable;
\r
228 xEthInit.ETH_FlushReceivedFrame = ETH_FlushReceivedFrame_Disable;
\r
229 xEthInit.ETH_TransmitStoreForward = ETH_TransmitStoreForward_Enable;
\r
230 xEthInit.ETH_TransmitThresholdControl = ETH_TransmitThresholdControl_64Bytes;
\r
231 xEthInit.ETH_ForwardErrorFrames = ETH_ForwardErrorFrames_Disable;
\r
232 xEthInit.ETH_ForwardUndersizedGoodFrames = ETH_ForwardUndersizedGoodFrames_Disable;
\r
233 xEthInit.ETH_ReceiveThresholdControl = ETH_ReceiveThresholdControl_64Bytes;
\r
234 xEthInit.ETH_SecondFrameOperate = ETH_SecondFrameOperate_Disable;
\r
235 xEthInit.ETH_AddressAlignedBeats = ETH_AddressAlignedBeats_Enable;
\r
236 xEthInit.ETH_FixedBurst = ETH_FixedBurst_Disable;
\r
237 xEthInit.ETH_RxDMABurstLength = ETH_RxDMABurstLength_1Beat;
\r
238 xEthInit.ETH_TxDMABurstLength = ETH_TxDMABurstLength_1Beat;
\r
239 xEthInit.ETH_DescriptorSkipLength = 0x0;
\r
240 xEthInit.ETH_DMAArbitration = ETH_DMAArbitration_RoundRobin_RxTx_1_1;
\r
242 xReturn = ETH_Init( &xEthInit, uipPHY_ADDRESS );
\r
244 /* Check a link was established. */
\r
245 if( xReturn != pdFAIL )
\r
247 /* Rx and Tx interrupts are used. */
\r
248 ETH_DMAITConfig( ETH_DMA_IT_NIS | ETH_DMA_IT_R | ETH_DMA_IT_T, ENABLE );
\r
250 /* Only a single Tx descriptor is used. For now it is set to use an Rx
\r
251 buffer, but will get updated to point to where ever uip_buf is
\r
252 pointing prior to its use. */
\r
253 ETH_DMATxDescChainInit( ( void * ) &xTxDescriptor, ( void * ) ucMACBuffers, 1 );
\r
254 ETH_DMARxDescChainInit( xRxDescriptors, ( void * ) ucMACBuffers, uipNUM_RX_DESCRIPTORS );
\r
255 for( ul = 0; ul < uipNUM_RX_DESCRIPTORS; ul++ )
\r
257 /* Ensure received data generates an interrupt. */
\r
258 ETH_DMARxDescReceiveITConfig( &( xRxDescriptors[ ul ] ), ENABLE );
\r
260 /* Fix up the addresses used by the descriptors.
\r
261 The way ETH_DMARxDescChainInit() is not compatible with the buffer
\r
262 declarations in this file. */
\r
263 xRxDescriptors[ ul ].Buffer1Addr = ( unsigned long ) &( ucMACBuffers[ ul ][ 0 ] );
\r
265 /* Mark the buffer used by this descriptor as in use. */
\r
266 ucBufferInUse[ ul ] = pdTRUE;
\r
269 /* When receiving data, start at the first descriptor. */
\r
270 ulNextDescriptor = 0;
\r
272 /* Initialise uip_buf to ensure it points somewhere valid. */
\r
273 uip_buf = prvGetNextBuffer();
\r
275 /* SendCount must be initialised to 2 to ensure the Tx descriptor looks
\r
276 as if its available (as if it has already been sent twice. */
\r
277 xTxDescriptor.SendCount = 2;
\r
279 /* Switch on the interrupts in the NVIC. */
\r
280 xNVICInit.NVIC_IRQChannel = uipENET_IRQ_NUM;
\r
281 xNVICInit.NVIC_IRQChannelPreemptionPriority = configLIBRARY_KERNEL_INTERRUPT_PRIORITY;
\r
282 xNVICInit.NVIC_IRQChannelSubPriority = 0;
\r
283 xNVICInit.NVIC_IRQChannelCmd = ENABLE;
\r
284 NVIC_Init( &xNVICInit );
\r
286 /* Buffers and descriptors are all set up, now enable the MAC. */
\r
289 /* Let the DMA know there are Rx descriptors available. */
\r
290 prvRxDescriptorAvailable();
\r
295 /*-----------------------------------------------------------*/
\r
297 static unsigned char *prvGetNextBuffer( void )
\r
300 unsigned char *ucReturn = NULL;
\r
301 unsigned long ulAttempts = 0;
\r
303 while( ucReturn == NULL )
\r
305 /* Look through the buffers to find one that is not in use by
\r
307 for( x = 0; x < uipNUM_BUFFERS; x++ )
\r
309 if( ucBufferInUse[ x ] == pdFALSE )
\r
311 ucBufferInUse[ x ] = pdTRUE;
\r
312 ucReturn = &( ucMACBuffers[ x ][ 0 ] );
\r
317 /* Was a buffer found? */
\r
318 if( ucReturn == NULL )
\r
322 if( ulAttempts >= uipBUFFER_WAIT_ATTEMPTS )
\r
327 /* Wait then look again. */
\r
328 vTaskDelay( uipBUFFER_WAIT_DELAY );
\r
334 /*-----------------------------------------------------------*/
\r
336 unsigned short usGetMACRxData( void )
\r
338 unsigned short usReturn;
\r
340 if( ( xRxDescriptors[ ulNextDescriptor ].Status & ETH_DMARxDesc_ES ) != 0 )
\r
342 /* Error in Rx. Discard the frame and give it back to the DMA. */
\r
343 xRxDescriptors[ ulNextDescriptor ].Status = ETH_DMARxDesc_OWN;
\r
344 prvRxDescriptorAvailable();
\r
346 /* No data to return. */
\r
349 /* Start from the next descriptor the next time this function is called. */
\r
350 ulNextDescriptor++;
\r
351 if( ulNextDescriptor >= uipNUM_RX_DESCRIPTORS )
\r
353 ulNextDescriptor = 0UL;
\r
356 else if( ( xRxDescriptors[ ulNextDescriptor ].Status & ETH_DMARxDesc_OWN ) == 0 )
\r
358 /* Mark the current buffer as free as uip_buf is going to be set to
\r
359 the buffer that contains the received data. */
\r
360 vReturnBuffer( uip_buf );
\r
362 /* Get the received data length from the top 2 bytes of the Status
\r
363 word and the data itself. */
\r
364 usReturn = ( unsigned short ) ( ( xRxDescriptors[ ulNextDescriptor ].Status & ETH_DMARxDesc_FL ) >> 16UL );
\r
365 uip_buf = ( unsigned char * ) ( xRxDescriptors[ ulNextDescriptor ].Buffer1Addr );
\r
367 /* Allocate a new buffer to the descriptor. */
\r
368 xRxDescriptors[ ulNextDescriptor ].Buffer1Addr = ( unsigned long ) prvGetNextBuffer();
\r
370 /* Give the descriptor back to the DMA. */
\r
371 xRxDescriptors[ ulNextDescriptor ].Status = ETH_DMARxDesc_OWN;
\r
372 prvRxDescriptorAvailable();
\r
374 /* Start from the next descriptor the next time this function is called. */
\r
375 ulNextDescriptor++;
\r
376 if( ulNextDescriptor >= uipNUM_RX_DESCRIPTORS )
\r
378 ulNextDescriptor = 0UL;
\r
383 /* No received data at all. */
\r
389 /*-----------------------------------------------------------*/
\r
391 void vSendMACData( unsigned short usDataLen )
\r
393 unsigned long ulAttempts = 0UL;
\r
395 /* Check to see if the Tx descriptor is free. The check against <2 is to
\r
396 ensure the buffer has been sent twice and in so doing preventing a race
\r
397 condition with the DMA on the ETH_DMATxDesc_OWN bit. */
\r
398 while( ( xTxDescriptor.SendCount < 2 ) && ( xTxDescriptor.Status & ETH_DMATxDesc_OWN ) == ETH_DMATxDesc_OWN )
\r
400 /* Wait for the Tx descriptor to become available. */
\r
401 vTaskDelay( uipBUFFER_WAIT_DELAY );
\r
404 if( ulAttempts > uipBUFFER_WAIT_ATTEMPTS )
\r
406 /* Something has gone wrong as the Tx descriptor is still in use.
\r
407 Clear it down manually, the data it was sending will probably be
\r
409 xTxDescriptor.Status &= ~ETH_DMATxDesc_OWN;
\r
410 vReturnBuffer( ( unsigned char * ) xTxDescriptor.Buffer1Addr );
\r
415 /* Setup the Tx descriptor for transmission. */
\r
416 xTxDescriptor.SendCount = 0;
\r
417 xTxDescriptor.Buffer1Addr = ( unsigned long ) uip_buf;
\r
418 xTxDescriptor.ControlBufferSize = ( unsigned long ) usDataLen;
\r
419 xTxDescriptor.Status = ETH_DMATxDesc_OWN | ETH_DMATxDesc_LS | ETH_DMATxDesc_FS | ETH_DMATxDesc_TER | ETH_DMATxDesc_TCH | ETH_DMATxDesc_IC;
\r
420 ETH_DMA->DMASR = ETH_DMASR_TBUS;
\r
421 ETH_DMA->DMATPDR = 0;
\r
423 /* uip_buf is being sent by the Tx descriptor. Allocate a new buffer. */
\r
424 uip_buf = prvGetNextBuffer();
\r
426 /*-----------------------------------------------------------*/
\r
428 static void prvSetupEthGPIO( void )
\r
430 GPIO_InitTypeDef xEthInit;
\r
432 /* Remap MAC IO. */
\r
433 AFIO->MAPR |= ( uipREMAP_MAC_IO );
\r
435 /* Set PA2, PA8, PB5, PB8, PB11, PB12, PB13, PC1 and PC2 for Ethernet
\r
437 xEthInit.GPIO_Pin = GPIO_Pin_2;/* | GPIO_Pin_8; This should be set when the 25MHz is generated by MCO. */
\r
438 xEthInit.GPIO_Speed = GPIO_Speed_50MHz;
\r
439 xEthInit.GPIO_Mode = GPIO_Mode_AF_PP;
\r
440 GPIO_Init( GPIOA, &xEthInit );
\r
442 xEthInit.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_8 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13; /*5*/
\r
443 GPIO_Init( GPIOB, &xEthInit );
\r
445 xEthInit.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2;
\r
446 GPIO_Init( GPIOC, &xEthInit );
\r
449 /* Configure PA0, PA1, PA3, PB10, PC3, PD8, PD9, PD10, PD11 and PD12 as
\r
451 xEthInit.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3;
\r
452 xEthInit.GPIO_Mode = GPIO_Mode_IN_FLOATING;
\r
453 GPIO_Init( GPIOA, &xEthInit );
\r
455 xEthInit.GPIO_Pin = GPIO_Pin_10;
\r
456 GPIO_Init( GPIOB, &xEthInit );
\r
458 xEthInit.GPIO_Pin = GPIO_Pin_3;
\r
459 GPIO_Init( GPIOC, &xEthInit );
\r
461 xEthInit.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12;
\r
462 GPIO_Init( GPIOD, &xEthInit );
\r
464 /*-----------------------------------------------------------*/
\r
466 void vReturnBuffer( unsigned char *pucBuffer )
\r
470 /* Mark a buffer as free for use. */
\r
471 for( ul = 0; ul < uipNUM_BUFFERS; ul++ )
\r
473 if( ucMACBuffers[ ul ] == pucBuffer )
\r
475 ucBufferInUse[ ul ] = pdFALSE;
\r
480 /*-----------------------------------------------------------*/
\r
482 void vMAC_ISR( void )
\r
484 unsigned long ulStatus;
\r
485 extern xSemaphoreHandle xEMACSemaphore;
\r
486 long xHigherPriorityTaskWoken = pdFALSE;
\r
488 /* What caused the interrupt? */
\r
489 ulStatus = ETH_DMA->DMASR;
\r
491 /* Clear everything before leaving. */
\r
492 ETH_DMA->DMASR = ulStatus;
\r
494 if( ulStatus & ETH_DMA_IT_R )
\r
496 /* Data was received. Ensure the uIP task is not blocked as data has
\r
498 xSemaphoreGiveFromISR( xEMACSemaphore, &xHigherPriorityTaskWoken );
\r
501 if( ulStatus & ETH_DMA_IT_T )
\r
503 /* Data was transmitted. */
\r
504 if( xTxDescriptor.SendCount == 0 )
\r
507 ( xTxDescriptor.SendCount )++;
\r
509 xTxDescriptor.Status = ETH_DMATxDesc_OWN | ETH_DMATxDesc_LS | ETH_DMATxDesc_FS | ETH_DMATxDesc_TER | ETH_DMATxDesc_TCH | ETH_DMATxDesc_IC;
\r
510 ETH_DMA->DMASR = ETH_DMASR_TBUS;
\r
511 ETH_DMA->DMATPDR = 0;
\r
515 /* The Tx buffer is no longer required. */
\r
516 vReturnBuffer( ( unsigned char * ) xTxDescriptor.Buffer1Addr );
\r
520 /* If xSemaphoreGiveFromISR() unblocked a task, and the unblocked task has
\r
521 a higher priority than the currently executing task, then
\r
522 xHigherPriorityTaskWoken will have been set to pdTRUE and this ISR should
\r
523 return directly to the higher priority unblocked task. */
\r
524 portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
\r