Skip to content

Commit 4bf345c

Browse files
committed
10.3.0-7
1 parent d586cb7 commit 4bf345c

File tree

3 files changed

+29
-43
lines changed

3 files changed

+29
-43
lines changed

library.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
name=FreeRTOS
2-
version=10.3.0-6
2+
version=10.3.0-7
33
author=Richard Barry <info@freertos.org>
44
maintainer=Phillip Stevens <phillip.stevens@gmail.com>
5-
sentence=FreeRTOS Real Time Operating System implemented for AVR (Uno, Leonardo, Mega).
5+
sentence=<h3>FreeRTOS Real Time Operating System implemented for AVR (Uno, Nano, Leonardo, Mega).</h3>
66
paragraph=The primary design goals are: Easy to use, Small footprint, Robust. Uses Watchdog Timer for 15ms resolution. Slow blink = stack overflow. Fast blink = heap malloc() failure.
77
category=Timing
88
url=https://github.com/feilipu/Arduino_FreeRTOS_Library

src/port.c

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ any details of its type. */
5050
typedef void TCB_t;
5151
extern volatile TCB_t * volatile pxCurrentTCB;
5252

53-
/*-----------------------------------------------------------*/
54-
/*
55-
* Perform hardware setup to enable ticks from Watchdog Timer.
56-
*/
57-
static void prvSetupTimerInterrupt( void );
58-
5953
/*-----------------------------------------------------------*/
6054

6155
/*
@@ -374,6 +368,11 @@ static void prvSetupTimerInterrupt( void );
374368
#endif
375369
/*-----------------------------------------------------------*/
376370

371+
/*
372+
* Perform hardware setup to enable ticks from Watchdog Timer.
373+
*/
374+
static void prvSetupTimerInterrupt( void );
375+
/*-----------------------------------------------------------*/
377376

378377
/*
379378
* See header file for description.
@@ -397,36 +396,28 @@ uint16_t usAddress;
397396

398397
/* The start of the task code will be popped off the stack last, so place
399398
it on first. */
399+
usAddress = ( uint16_t ) pxCode;
400+
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
401+
pxTopOfStack--;
402+
403+
usAddress >>= 8;
404+
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
405+
pxTopOfStack--;
400406

401407
#if defined(__AVR_3_BYTE_PC__)
402408
/* The AVR ATmega2560/ATmega2561 have 256KBytes of program memory and a 17-bit
403-
* program counter. When a code address is stored on the stack, it takes 3 bytes
409+
* program counter. When a code address is stored on the stack, it takes 3 bytes
404410
* instead of 2 for the other ATmega* chips.
405411
*
406412
* Store 0 as the top byte since we force all task routines to the bottom 128K
407413
* of flash. We do this by using the .lowtext label in the linker script.
408414
*
409415
* In order to do this properly, we would need to get a full 3-byte pointer to
410-
* pxCode. That requires a change to GCC. Not likely to happen any time soon.
416+
* pxCode. That requires a change to GCC. Not likely to happen any time soon.
411417
*/
412-
usAddress = ( uint16_t ) pxCode;
413-
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
414-
pxTopOfStack--;
415-
416-
usAddress >>= 8;
417-
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
418-
pxTopOfStack--;
419418

420419
*pxTopOfStack = 0;
421420
pxTopOfStack--;
422-
#else
423-
usAddress = ( uint16_t ) pxCode;
424-
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
425-
pxTopOfStack--;
426-
427-
usAddress >>= 8;
428-
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
429-
pxTopOfStack--;
430421
#endif
431422

432423
/* Next simulate the stack as if after a call to portSAVE_CONTEXT().
@@ -454,7 +445,7 @@ uint16_t usAddress;
454445
pxTopOfStack--;
455446
#endif
456447

457-
/* Now the remaining registers. The compiler expects R1 to be 0. */
448+
/* Now the remaining registers. The compiler expects R1 to be 0. */
458449
*pxTopOfStack = ( StackType_t ) 0x00; /* R1 */
459450
pxTopOfStack--;
460451
*pxTopOfStack = ( StackType_t ) 0x02; /* R2 */
@@ -521,7 +512,7 @@ uint16_t usAddress;
521512
pxTopOfStack--;
522513
*pxTopOfStack = ( StackType_t ) 0x30; /* R30 Z */
523514
pxTopOfStack--;
524-
*pxTopOfStack = ( StackType_t ) 0x031; /* R31 */
515+
*pxTopOfStack = ( StackType_t ) 0x031; /* R31 */
525516
pxTopOfStack--;
526517

527518
return pxTopOfStack;
@@ -536,7 +527,7 @@ BaseType_t xPortStartScheduler( void )
536527
/* Restore the context of the first task that is going to run. */
537528
portRESTORE_CONTEXT();
538529

539-
/* Simulate a function call end as generated by the compiler. We will now
530+
/* Simulate a function call end as generated by the compiler. We will now
540531
jump to the start of the task the context of which we have just restored. */
541532
__asm__ __volatile__ ( "ret" );
542533

@@ -550,12 +541,12 @@ void vPortEndScheduler( void )
550541
/* It is unlikely that the AVR port will get stopped. If required simply
551542
disable the tick interrupt here. */
552543

553-
wdt_disable(); // disable Watchdog Timer
544+
wdt_disable(); /* disable Watchdog Timer */
554545
}
555546
/*-----------------------------------------------------------*/
556547

557548
/*
558-
* Manual context switch. The first thing we do is save the registers so we
549+
* Manual context switch. The first thing we do is save the registers so we
559550
* can use a naked attribute.
560551
*/
561552
void vPortYield( void ) __attribute__ ( ( hot, flatten, naked ) );
@@ -570,23 +561,20 @@ void vPortYield( void )
570561
/*-----------------------------------------------------------*/
571562

572563
/*
573-
* Context switch function used by the tick. This must be identical to
574-
* vPortYield() from the call to vTaskSwitchContext() onwards. The only
564+
* Context switch function used by the tick. This must be identical to
565+
* vPortYield() from the call to vTaskSwitchContext() onwards. The only
575566
* difference from vPortYield() is the tick count is incremented as the
576567
* call comes from the tick ISR.
577568
*/
578569
void vPortYieldFromTick( void ) __attribute__ ( ( hot, flatten, naked ) );
579570
void vPortYieldFromTick( void )
580571
{
581572
portSAVE_CONTEXT();
582-
583-
sleep_reset(); // reset the sleep_mode() faster than sleep_disable();
584-
573+
sleep_reset(); /* reset the sleep_mode() faster than sleep_disable(); */
585574
if( xTaskIncrementTick() != pdFALSE )
586575
{
587576
vTaskSwitchContext();
588577
}
589-
590578
portRESTORE_CONTEXT();
591579

592580
__asm__ __volatile__ ( "ret" );
@@ -604,14 +592,13 @@ void prvSetupTimerInterrupt( void )
604592
/* set up WDT Interrupt (rather than the WDT Reset). */
605593
wdt_interrupt_enable( portUSE_WDTO );
606594
}
607-
608595
/*-----------------------------------------------------------*/
609596

610597
#if configUSE_PREEMPTION == 1
611598

612599
/*
613-
* Tick ISR for preemptive scheduler. We can use a naked attribute as
614-
* the context is saved at the start of vPortYieldFromTick(). The tick
600+
* Tick ISR for preemptive scheduler. We can use a naked attribute as
601+
* the context is saved at the start of vPortYieldFromTick(). The tick
615602
* count is incremented after the context is saved.
616603
*
617604
* use ISR_NOBLOCK where there is an important timer running, that should preempt the scheduler.
@@ -628,8 +615,8 @@ void prvSetupTimerInterrupt( void )
628615
#else
629616

630617
/*
631-
* Tick ISR for the cooperative scheduler. All this does is increment the
632-
* tick count. We don't need to switch context, this can only be done by
618+
* Tick ISR for the cooperative scheduler. All this does is increment the
619+
* tick count. We don't need to switch context, this can only be done by
633620
* manual calls to taskYIELD();
634621
*
635622
* use ISR_NOBLOCK where there is an important timer running, that should preempt the scheduler.

src/portmacro.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,11 @@ typedef uint8_t UBaseType_t;
7676

7777
#define portDISABLE_INTERRUPTS() __asm__ __volatile__ ( "cli" ::: "memory")
7878
#define portENABLE_INTERRUPTS() __asm__ __volatile__ ( "sei" ::: "memory")
79-
8079
/*-----------------------------------------------------------*/
8180

8281
/* Architecture specifics. */
8382

84-
#define sleep_reset() do { _SLEEP_CONTROL_REG = 0; } while(0) // reset all sleep_mode() configurations.
83+
#define sleep_reset() do { _SLEEP_CONTROL_REG = 0; } while(0) /* reset all sleep_mode() configurations. */
8584

8685
#define portSTACK_GROWTH ( -1 )
8786

0 commit comments

Comments
 (0)