FreeRTOS Plus IO, LPC1769 UART IRQ Handler

joshuanapoli wrote on Friday, September 14, 2012:

I am setting up FreeRTOS+IO for a LPC1765 MCU. I was working from the LPC1769_FreeRTOS_Plus_Featured_Demo package, where the FreeRTOS_IO.h has version 1.0.0.

The problem I’m running into is that the UART IRQ handler is only implemented for UART3. Is there a more complete FreeRTOS+IO package that I should use? Or should I just implement the IRQ handlers for the UARTs that I need?


rtel wrote on Friday, September 14, 2012:

Please just create the other UART from the existing UART3.  The idea is to keep board support packages that are specific to hardware, and that particular hardware has access to UART3 only.

I have discovered a very small patch to the kernel is required in that version.  vTaskPriorityInherit() in FreeRTOS/Source/tasks.c needs a minor modification as follows:

	void vTaskPriorityInherit( xTaskHandle * const pxMutexHolder )
tskTCB * const pxTCB = ( tskTCB * ) pxMutexHolder;
	/* If the mutex was given back by an interrupt while the queue was
	locked then the mutex holder might now be NULL. */
	if( pxMutexHolder != NULL ) //<<<<ADDED LINE
		if( pxTCB->uxPriority < pxCurrentTCB->uxPriority )
			/* Adjust the mutex holder state to account for its new priority. */
			listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxCurrentTCB->uxPriority );
			/* If the task being modified is in the ready state it will need to
			be moved in to a new list. */
			if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ pxTCB->uxPriority ] ), &( pxTCB->xGenericListItem ) ) != pdFALSE )
				vListRemove( &( pxTCB->xGenericListItem ) );
				/* Inherit the priority before being moved into the new list. */
				pxTCB->uxPriority = pxCurrentTCB->uxPriority;
				prvAddTaskToReadyQueue( pxTCB );
				/* Just inherit the priority. */
				pxTCB->uxPriority = pxCurrentTCB->uxPriority;
			traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority );

Apologies for this, it is a recent find and not documented yet.  I need to put an errata up until the code is changed.  (the change is required because a mutex is used where really a binary semaphore (without priority inheritance) should have been used instead.

There are some improvements and enhancements to the user model in the pipeline for the IO code that will introduce some short-cuts to remove the need for the ioctl calls when using the zero copy mode.  Watch this space!