]> begriffs open source - cmsis-freertos/blob - Demo/CORTEX_LM3S102_GCC/Demo1/main.c
Update cmsis_os2.c
[cmsis-freertos] / Demo / CORTEX_LM3S102_GCC / Demo1 / main.c
1 /*
2     FreeRTOS V9.0.0 - Copyright (C) 2016 Real Time Engineers Ltd.
3     All rights reserved
4
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
6
7     This file is part of the FreeRTOS distribution.
8
9     FreeRTOS is free software; you can redistribute it and/or modify it under
10     the terms of the GNU General Public License (version 2) as published by the
11     Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
12
13     ***************************************************************************
14     >>!   NOTE: The modification to the GPL is included to allow you to     !<<
15     >>!   distribute a combined work that includes FreeRTOS without being   !<<
16     >>!   obliged to provide the source code for proprietary components     !<<
17     >>!   outside of the FreeRTOS kernel.                                   !<<
18     ***************************************************************************
19
20     FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
21     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22     FOR A PARTICULAR PURPOSE.  Full license text is available on the following
23     link: http://www.freertos.org/a00114.html
24
25     ***************************************************************************
26      *                                                                       *
27      *    FreeRTOS provides completely free yet professionally developed,    *
28      *    robust, strictly quality controlled, supported, and cross          *
29      *    platform software that is more than just the market leader, it     *
30      *    is the industry's de facto standard.                               *
31      *                                                                       *
32      *    Help yourself get started quickly while simultaneously helping     *
33      *    to support the FreeRTOS project by purchasing a FreeRTOS           *
34      *    tutorial book, reference manual, or both:                          *
35      *    http://www.FreeRTOS.org/Documentation                              *
36      *                                                                       *
37     ***************************************************************************
38
39     http://www.FreeRTOS.org/FAQHelp.html - Having a problem?  Start by reading
40     the FAQ page "My application does not run, what could be wrong?".  Have you
41     defined configASSERT()?
42
43     http://www.FreeRTOS.org/support - In return for receiving this top quality
44     embedded software for free we request you assist our global community by
45     participating in the support forum.
46
47     http://www.FreeRTOS.org/training - Investing in training allows your team to
48     be as productive as possible as early as possible.  Now you can receive
49     FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
50     Ltd, and the world's leading authority on the world's leading RTOS.
51
52     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
53     including FreeRTOS+Trace - an indispensable productivity tool, a DOS
54     compatible FAT file system, and our tiny thread aware UDP/IP stack.
55
56     http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
57     Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
58
59     http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
60     Integrity Systems ltd. to sell under the OpenRTOS brand.  Low cost OpenRTOS
61     licenses offer ticketed support, indemnification and commercial middleware.
62
63     http://www.SafeRTOS.com - High Integrity Systems also provide a safety
64     engineered and independently SIL3 certified version for use in safety and
65     mission critical applications that require provable dependability.
66
67     1 tab == 4 spaces!
68 */
69
70 /* 
71  * This demo application creates six co-routines and two tasks (three including 
72  * the idle task).  The co-routines execute as part of the idle task hook.
73  *
74  * Five of the created co-routines are the standard 'co-routine flash' 
75  * co-routines contained within the Demo/Common/Minimal/crflash.c file and 
76  * documented on the FreeRTOS.org WEB site.  
77  *
78  * The 'LCD Task' rotates a string on the LCD, delaying between each character
79  * as necessitated by the slow interface, and delaying between each string just
80  * long enough to enable the text to be read.
81  *
82  * The sixth co-routine and final task control the transmission and reception
83  * of a string to UART 0.  The co-routine periodically sends the first 
84  * character of the string to the UART, with the UART's TxEnd interrupt being
85  * used to transmit the remaining characters.  The UART's RxEnd interrupt 
86  * receives the characters and places them on a queue to be processed by the 
87  * 'COMs Rx' task.  An error is latched should an unexpected character be 
88  * received, or any character be received out of sequence.  
89  *
90  * A loopback connector is required to ensure that each character transmitted 
91  * on the UART is also received on the same UART.  For test purposes the UART
92  * FIFO's are not utalised in order to maximise the interrupt overhead.  Also
93  * a pseudo random interval is used between the start of each transmission in 
94  * order that the resultant interrupts are more randomly distributed and 
95  * therefore more likely to highlight any problems.
96  *
97  * The flash co-routines control LED's zero to four.  LED five is toggled each
98  * time the string is transmitted on the UART.  LED six is toggled each time
99  * the string is CORRECTLY received on the UART.  LED seven is latched on should
100  * an error be detected in any task or co-routine.
101  *
102  * In addition the idle task makes repetative calls to 
103  * prvSetAndCheckRegisters().  This simply loads the general purpose registers 
104  * with a known value, then checks each register to ensure the held value is 
105  * still correct.  As a low priority task this checking routine is likely to 
106  * get repeatedly swapped in and out.  A register being found to contain an 
107  * incorrect value is therefore indicative of an error in the task switching 
108  * mechansim.
109  *
110  */
111
112 /* Scheduler include files. */
113 #include "FreeRTOS.h"
114 #include "task.h"
115 #include "queue.h"
116 #include "croutine.h"
117
118 /* Demo application include files. */
119 #include "partest.h"
120 #include "crflash.h"
121
122 /* Library include files. */
123 #include "DriverLib.h"
124
125 /* The time to delay between writing each character to the LCD. */
126 #define mainCHAR_WRITE_DELAY            ( 2 / portTICK_PERIOD_MS )
127
128 /* The time to delay between writing each string to the LCD. */
129 #define mainSTRING_WRITE_DELAY          ( 400 / portTICK_PERIOD_MS )
130
131 /* The number of flash co-routines to create. */
132 #define mainNUM_FLASH_CO_ROUTINES       ( 5 )
133
134 /* The length of the queue used to pass received characters to the Comms Rx
135 task. */
136 #define mainRX_QUEUE_LEN                        ( 5 )
137
138 /* The priority of the co-routine used to initiate the transmission of the 
139 string on UART 0. */
140 #define mainTX_CO_ROUTINE_PRIORITY      ( 1 )
141
142 /* Only one co-routine is created so its index is not important. */
143 #define mainTX_CO_ROUTINE_INDEX         ( 0 )
144
145 /* The time between transmissions of the string on UART 0.   This is pseudo
146 random in order to generate a bit or randomness to when the interrupts occur.*/
147 #define mainMIN_TX_DELAY                        ( 40 / portTICK_PERIOD_MS )
148 #define mainMAX_TX_DELAY                        ( ( TickType_t ) 0x7f )
149 #define mainOFFSET_TIME                         ( ( TickType_t ) 3 )
150
151 /* The time the Comms Rx task should wait to receive a character.  This should
152 be slightly longer than the time between transmissions.  If we do not receive
153 a character after this time then there must be an error in the transmission or
154 the timing of the transmission. */
155 #define mainCOMMS_RX_DELAY                      ( mainMAX_TX_DELAY + 20 )
156
157 /* The task priorites. */
158 #define mainLCD_TASK_PRIORITY           ( tskIDLE_PRIORITY )
159 #define mainCOMMS_RX_TASK_PRIORITY      ( tskIDLE_PRIORITY + 1 )
160
161 /* The LED's toggled by the various tasks. */
162 #define mainCOMMS_FAIL_LED                      ( 7 )
163 #define mainCOMMS_RX_LED                        ( 6 )
164 #define mainCOMMS_TX_LED                        ( 5 )
165
166 /* The baud rate used by the UART comms tasks/co-routine. */
167 #define mainBAUD_RATE                           ( 57600 )
168
169 /* FIFO setting for the UART.  The FIFO is not used to create a better test. */
170 #define mainFIFO_SET                            ( 0x10 )
171
172 /* The string that is transmitted on the UART contains sequentially the 
173 characters from mainFIRST_TX_CHAR to mainLAST_TX_CHAR. */
174 #define mainFIRST_TX_CHAR '0'
175 #define mainLAST_TX_CHAR 'z'
176
177 /* Just used to walk through the program memory in order that some random data
178 can be generated. */
179 #define mainTOTAL_PROGRAM_MEMORY ( ( unsigned long * ) ( 8 * 1024 ) )
180 #define mainFIRST_PROGRAM_BYTES ( ( unsigned long * ) 4 )
181
182 /* The error routine that is called if the driver library encounters an error. */
183 #ifdef DEBUG
184 void
185 __error__(char *pcFilename, unsigned long ulLine)
186 {
187 }
188 #endif
189
190 /*-----------------------------------------------------------*/
191
192 /*
193  * The task that rotates text on the LCD.
194  */
195 static void vLCDTask( void * pvParameters );
196
197 /*
198  * The task that receives the characters from UART 0.
199  */
200 static void vCommsRxTask( void * pvParameters );
201
202 /*
203  * The co-routine that periodically initiates the transmission of the string on
204  * the UART.
205  */
206 static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex );
207
208 /* 
209  * Writes a string the the LCD.
210  */
211 static void prvWriteString( const char *pcString );
212
213 /*
214  * Initialisation routine for the UART.
215  */
216 static void vSerialInit( void );
217
218 /*
219  * Thread safe write to the PDC.
220  */
221 static void prvPDCWrite( char cAddress, char cData );
222
223 /*
224  * Function to simply set a known value into the general purpose registers
225  * then read them back to ensure they remain set correctly.  An incorrect value
226  * being indicative of an error in the task switching mechanism.
227  */
228 void prvSetAndCheckRegisters( void );
229
230 /*
231  * Latch the LED that indicates that an error has occurred. 
232  */
233 void vSetErrorLED( void );
234
235 /*
236  * Sets up the PLL and ports used by the demo.
237  */
238 static void prvSetupHardware( void );
239
240 /*-----------------------------------------------------------*/
241
242 /* Error flag set to pdFAIL if an error is encountered in the tasks/co-routines
243 defined within this file. */
244 unsigned portBASE_TYPE uxErrorStatus = pdPASS;
245
246 /* The next character to transmit. */
247 static char cNextChar;
248
249 /* The queue used to transmit characters from the interrupt to the Comms Rx
250 task. */
251 static QueueHandle_t xCommsQueue;
252
253 /*-----------------------------------------------------------*/
254
255 void Main( void )
256 {
257         /* Create the queue used to communicate between the UART ISR and the Comms
258         Rx task. */
259         xCommsQueue = xQueueCreate( mainRX_QUEUE_LEN, sizeof( char ) );
260
261         /* Setup the ports used by the demo and the clock. */
262         prvSetupHardware();
263
264         /* Create the co-routines that flash the LED's. */
265         vStartFlashCoRoutines( mainNUM_FLASH_CO_ROUTINES );
266
267         /* Create the co-routine that initiates the transmission of characters
268         on the UART. */
269         xCoRoutineCreate( vSerialTxCoRoutine, mainTX_CO_ROUTINE_PRIORITY, mainTX_CO_ROUTINE_INDEX );
270
271         /* Create the LCD and Comms Rx tasks. */
272         xTaskCreate( vLCDTask, "LCD", configMINIMAL_STACK_SIZE, NULL, mainLCD_TASK_PRIORITY, NULL );
273         xTaskCreate( vCommsRxTask, "CMS", configMINIMAL_STACK_SIZE, NULL, mainCOMMS_RX_TASK_PRIORITY, NULL );
274
275         /* Start the scheduler running the tasks and co-routines just created. */
276         vTaskStartScheduler();
277
278         /* Should not get here unless we did not have enough memory to start the
279         scheduler. */
280         for( ;; );
281 }
282 /*-----------------------------------------------------------*/
283
284 static void prvSetupHardware( void )
285 {
286         /* Setup the PLL. */
287         SysCtlClockSet( SYSCTL_SYSDIV_10 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ );
288
289         /* Initialise the hardware used to talk to the LCD, LED's and UART. */
290         PDCInit();
291         vParTestInitialise();
292         vSerialInit();
293 }
294 /*-----------------------------------------------------------*/
295
296 void vApplicationIdleHook( void )
297 {
298         /* The co-routines are executed in the idle task using the idle task 
299         hook. */
300         for( ;; )
301         {
302                 /* Schedule the co-routines. */
303                 vCoRoutineSchedule();
304
305                 /* Run the register check function between each co-routine. */
306                 prvSetAndCheckRegisters();
307         }
308 }
309 /*-----------------------------------------------------------*/
310
311 static void prvWriteString( const char *pcString )
312 {
313         /* Write pcString to the LED, pausing between each character. */
314         prvPDCWrite(PDC_LCD_CSR, LCD_CLEAR);        
315         while( *pcString )
316         {
317                 vTaskDelay( mainCHAR_WRITE_DELAY );
318                 prvPDCWrite( PDC_LCD_RAM, *pcString );
319                 pcString++;
320         }
321 }
322 /*-----------------------------------------------------------*/
323
324 void vLCDTask( void * pvParameters )
325 {
326 unsigned portBASE_TYPE uxIndex;
327 const unsigned char ucCFGData[] = {     
328                                                                                         0x30,   /* Set data bus to 8-bits. */
329                                                                                         0x30,
330                                                                                         0x30,
331                                                                                         0x3C,   /* Number of lines/font. */
332                                                                                         0x08,   /* Display off. */
333                                                                                         0x01,   /* Display clear. */
334                                                                                         0x06,   /* Entry mode [cursor dir][shift]. */
335                                                                                         0x0C    /* Display on [display on][curson on][blinking on]. */
336                                                                           };  
337
338 /* The strings that are written to the LCD. */
339 const char *pcStringsToDisplay[] = {                                                                            
340                                                                                         "Stellaris",
341                                                                                         "Demo",
342                                                                                         "One",
343                                                                                         "www.FreeRTOS.org",
344                                                                                         ""
345                                                                            };
346
347         /* Configure the LCD. */
348         uxIndex = 0;
349         while( uxIndex < sizeof( ucCFGData ) )
350         {
351                 prvPDCWrite( PDC_LCD_CSR, ucCFGData[ uxIndex ] );
352                 uxIndex++;
353                 vTaskDelay( mainCHAR_WRITE_DELAY );
354         }
355
356         /* Turn the LCD Backlight on. */
357         prvPDCWrite( PDC_CSR, 0x01 );
358
359         /* Clear display. */
360         vTaskDelay( mainCHAR_WRITE_DELAY );
361         prvPDCWrite( PDC_LCD_CSR, LCD_CLEAR ); 
362
363         uxIndex = 0;
364         for( ;; )    
365         {
366                 /* Display the string on the LCD. */
367                 prvWriteString( pcStringsToDisplay[ uxIndex ] );
368                 
369                 /* Move on to the next string - wrapping if necessary. */
370                 uxIndex++;
371                 if( *( pcStringsToDisplay[ uxIndex ] ) == 0x00 )
372                 {
373                         uxIndex = 0;
374                         /* Longer pause on the last string to be sent. */
375                         vTaskDelay( mainSTRING_WRITE_DELAY * 2 );
376                 }
377
378                 /* Wait until it is time to move onto the next string. */
379                 vTaskDelay( mainSTRING_WRITE_DELAY );
380         }
381 }
382 /*-----------------------------------------------------------*/
383
384 static void vCommsRxTask( void * pvParameters )
385 {
386 static char cRxedChar, cExpectedChar;
387
388         /* Set the char we expect to receive to the start of the string. */
389         cExpectedChar = mainFIRST_TX_CHAR;
390
391         for( ;; )
392         {
393                 /* Wait for a character to be received. */
394                 xQueueReceive( xCommsQueue, ( void * ) &cRxedChar, mainCOMMS_RX_DELAY );
395
396                 /* Was the character recived (if any) the expected character. */
397                 if( cRxedChar != cExpectedChar )
398                 {
399                         /* Got an unexpected character.  This can sometimes occur when
400                         reseting the system using the debugger leaving characters already
401                         in the UART regsters. */
402                         uxErrorStatus = pdFAIL;
403
404                         /* Resync by waiting for the end of the current string. */
405                         while( cRxedChar != mainLAST_TX_CHAR )
406                         {
407                                 while( !xQueueReceive( xCommsQueue, ( void * ) &cRxedChar, portMAX_DELAY ) );
408                         }
409
410                         /* The next expected character is the start of the string again. */
411                         cExpectedChar = mainFIRST_TX_CHAR;
412                 }
413                 else
414                 {
415                         if( cExpectedChar == mainLAST_TX_CHAR )
416                         {
417                                 /* We have reached the end of the string - we now expect to 
418                                 receive the first character in the string again.   The LED is 
419                                 toggled to indicate that the entire string was received without
420                                 error. */
421                                 vParTestToggleLED( mainCOMMS_RX_LED );
422                                 cExpectedChar = mainFIRST_TX_CHAR;
423                         }
424                         else
425                         {
426                                 /* We got the expected character, we now expect to receive the
427                                 next character in the string. */
428                                 cExpectedChar++;
429                         }
430                 }
431         }
432 }
433 /*-----------------------------------------------------------*/
434
435 static void vSerialTxCoRoutine( CoRoutineHandle_t xHandle, unsigned portBASE_TYPE uxIndex )
436 {
437 TickType_t xDelayPeriod;
438 static unsigned long *pulRandomBytes = mainFIRST_PROGRAM_BYTES;
439
440         /* Co-routine MUST start with a call to crSTART. */
441         crSTART( xHandle );
442
443         for(;;)
444     {   
445                 /* Was the previously transmitted string received correctly? */
446                 if( uxErrorStatus != pdPASS )
447                 {
448                         /* An error was encountered so set the error LED. */
449                         vSetErrorLED();
450                 }
451
452                 /* The next character to Tx is the first in the string. */
453                 cNextChar = mainFIRST_TX_CHAR;
454
455                 UARTIntDisable( UART0_BASE, UART_INT_TX );
456                 {
457                         /* Send the first character. */
458                         if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
459                         {
460                                 HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
461                         }
462
463                         /* Move the variable to the char to Tx on so the ISR transmits
464                         the next character in the string once this one has completed. */
465                         cNextChar++;
466                 }
467                 UARTIntEnable(UART0_BASE, UART_INT_TX);
468
469                 /* Toggle the LED to show a new string is being transmitted. */
470         vParTestToggleLED( mainCOMMS_TX_LED );
471
472                 /* Delay before we start the string off again.  A pseudo-random delay
473                 is used as this will provide a better test. */
474                 xDelayPeriod = xTaskGetTickCount() + ( *pulRandomBytes );
475
476                 pulRandomBytes++;
477                 if( pulRandomBytes > mainTOTAL_PROGRAM_MEMORY )
478                 {
479                         pulRandomBytes = mainFIRST_PROGRAM_BYTES;
480                 }
481
482                 /* Make sure we don't wait too long... */
483                 xDelayPeriod &= mainMAX_TX_DELAY;
484
485                 /* ...but we do want to wait. */
486                 if( xDelayPeriod < mainMIN_TX_DELAY )
487                 {
488                         xDelayPeriod = mainMIN_TX_DELAY;
489                 }
490
491                 /* Block for the random(ish) time. */
492                 crDELAY( xHandle, xDelayPeriod );
493     }
494
495         /* Co-routine MUST end with a call to crEND. */
496         crEND();
497 }
498 /*-----------------------------------------------------------*/
499
500 static void vSerialInit( void )
501 {
502         /* Enable the UART.  GPIOA has already been initialised. */
503         SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
504
505         /* Set GPIO A0 and A1 as peripheral function.  They are used to output the
506         UART signals. */
507         GPIODirModeSet( GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1, GPIO_DIR_MODE_HW );
508
509         /* Configure the UART for 8-N-1 operation. */
510         UARTConfigSet( UART0_BASE, mainBAUD_RATE, UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE );
511
512         /* We dont want to use the fifo.  This is for test purposes to generate
513         as many interrupts as possible. */
514         HWREG( UART0_BASE + UART_O_LCR_H ) &= ~mainFIFO_SET;
515
516         /* Enable both Rx and Tx interrupts. */
517         HWREG( UART0_BASE + UART_O_IM ) |= ( UART_INT_TX | UART_INT_RX );
518         IntEnable( INT_UART0 );
519 }
520 /*-----------------------------------------------------------*/
521
522 void vUART_ISR(void)
523 {
524 unsigned long ulStatus;
525 char cRxedChar;
526 portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
527
528         /* What caused the interrupt. */
529         ulStatus = UARTIntStatus( UART0_BASE, pdTRUE );
530
531         /* Clear the interrupt. */
532         UARTIntClear( UART0_BASE, ulStatus );
533
534         /* Was an Rx interrpt pending? */
535         if( ulStatus & UART_INT_RX )
536         {
537                 if( ( HWREG(UART0_BASE + UART_O_FR ) & UART_FR_RXFF ) )
538                 {
539                         /* Get the char from the buffer and post it onto the queue of
540                         Rxed chars.  Posting the character should wake the task that is 
541                         blocked on the queue waiting for characters. */
542                         cRxedChar = ( char ) HWREG( UART0_BASE + UART_O_DR );
543                         xQueueSendFromISR( xCommsQueue, &cRxedChar, &xHigherPriorityTaskWoken );
544                 }               
545         }
546
547         /* Was a Tx interrupt pending? */
548         if( ulStatus & UART_INT_TX )
549         {
550                 /* Send the next character in the string.  We are not using the FIFO. */
551                 if( cNextChar <= mainLAST_TX_CHAR )
552                 {
553                         if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) )
554                         {
555                                 HWREG( UART0_BASE + UART_O_DR ) = cNextChar;
556                         }
557                         cNextChar++;
558                 }
559         }
560         
561         /* If a task was woken by the character being received then we force
562         a context switch to occur in case the task is of higher priority than
563         the currently executing task (i.e. the task that this interrupt 
564         interrupted.) */
565         portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
566 }
567 /*-----------------------------------------------------------*/
568
569 static void prvPDCWrite( char cAddress, char cData )
570 {
571         vTaskSuspendAll();
572         {
573                 PDCWrite( cAddress, cData );
574         }
575         xTaskResumeAll();
576 }
577 /*-----------------------------------------------------------*/
578
579 void vSetErrorLED( void )
580 {
581         vParTestSetLED( mainCOMMS_FAIL_LED, pdTRUE );
582 }
583 /*-----------------------------------------------------------*/
584
585 void prvSetAndCheckRegisters( void )
586 {
587         /* Fill the general purpose registers with known values. */
588         __asm volatile( "    mov r11, #10\n"
589                   "    add r0, r11, #1\n"
590                   "    add r1, r11, #2\n"
591                         "    add r2, r11, #3\n"
592                         "    add r3, r11, #4\n"
593                         "    add r4, r11, #5\n"
594                         "    add r5, r11, #6\n"
595                         "    add r6, r11, #7\n"
596                         "    add r7, r11, #8\n"
597                         "    add r8, r11, #9\n"
598                         "    add r9, r11, #10\n"
599                         "    add r10, r11, #11\n"
600                         "    add r12, r11, #12" );
601
602         /* Check the values are as expected. */
603         __asm volatile( "    cmp r11, #10\n"
604                         "    bne set_error_led\n"
605                         "    cmp r0, #11\n"
606                         "    bne set_error_led\n"
607                         "    cmp r1, #12\n"
608                         "    bne set_error_led\n"
609                         "    cmp r2, #13\n"
610                         "    bne set_error_led\n"
611                         "    cmp r3, #14\n"
612                         "    bne set_error_led\n"
613                         "    cmp r4, #15\n"
614                         "    bne set_error_led\n"
615                         "    cmp r5, #16\n"
616                         "    bne set_error_led\n"
617                         "    cmp r6, #17\n"
618                         "    bne set_error_led\n"
619                         "    cmp r7, #18\n"
620                         "    bne set_error_led\n"
621                         "    cmp r8, #19\n"
622                         "    bne set_error_led\n"
623                         "    cmp r9, #20\n"
624                         "    bne set_error_led\n"
625                         "    cmp r10, #21\n"
626                         "    bne set_error_led\n"
627                         "    cmp r12, #22\n"
628                         "    bne set_error_led\n"
629                         "    bx lr" );
630
631   __asm volatile( "set_error_led:\n"
632                         "    push {r14}\n"
633                         "    ldr r1, =vSetErrorLED\n"
634                         "    blx r1\n"
635                         "    pop {r14}\n"
636                         "    bx lr" );
637 }
638 /*-----------------------------------------------------------*/