6cc948eef8
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@113 9fe90eed-be63-e94b-8204-d34ff4c2ff93
127 lines
4.2 KiB
C
127 lines
4.2 KiB
C
/* ---------------------------------------------------------------------------
|
|
* ssp0ISR.c - v0.1 (c) 2007 Micro-key bv
|
|
* ---------------------------------------------------------------------------
|
|
* Micro-key bv
|
|
* Industrieweg 28, 9804 TG Noordhorn
|
|
* Postbus 92, 9800 AB Zuidhorn
|
|
* The Netherlands
|
|
* Tel: +31 594 503020
|
|
* Fax: +31 594 505825
|
|
* Email: support@microkey.nl
|
|
* Web: www.microkey.nl
|
|
* ---------------------------------------------------------------------------
|
|
* Description: Interrupt service routine for SSP0
|
|
* ---------------------------------------------------------------------------
|
|
* Version(s): 0.1, 28-11-2007, fvds.
|
|
* Creation.
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* System include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Application include files
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
#include "LPC23xx.h"
|
|
#include "types.h"
|
|
|
|
#include "ssp1ISR.h"
|
|
//#include "armVIC.h"
|
|
|
|
/* FreeRTOS includes */
|
|
#include "FreeRTOS.h"
|
|
#include "Task.h"
|
|
#include "queue.h"
|
|
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local constant and macro definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Global variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
extern xQueueHandle ssp1DispatchedIsrQueue;
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local variable definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
/* statistics of all the interrupts */
|
|
static volatile UINT32 interruptRxStat = 0;
|
|
static volatile UINT32 interruptOverRunStat = 0;
|
|
static volatile UINT32 interruptRxTimeoutStat = 0;
|
|
static UINT8 receivedByte;
|
|
|
|
|
|
/* ---------------------------------------------------------------------------
|
|
* Local function definitions
|
|
* ---------------------------------------------------------------------------
|
|
*/
|
|
static void ssp1Handler( void );
|
|
|
|
|
|
void ssp1ISR( void )
|
|
{
|
|
/* Save the context of the interrupted task. */
|
|
portSAVE_CONTEXT();
|
|
{
|
|
ssp1Handler();
|
|
}
|
|
/* Restore the context of whichever task is going to run once the interrupt
|
|
completes. */
|
|
portRESTORE_CONTEXT();
|
|
}
|
|
|
|
void ssp1Handler( void )
|
|
{
|
|
UINT32 regValue;
|
|
|
|
regValue = SSP1MIS;
|
|
if ( regValue & SSPMIS_RORMIS ) /* Receive overrun interrupt */
|
|
{
|
|
interruptOverRunStat++;
|
|
SSP1ICR = SSPICR_RORIC; /* clear interrupt */
|
|
}
|
|
|
|
if ( regValue & SSPMIS_RTMIS ) /* Receive timeout interrupt */
|
|
{
|
|
interruptRxTimeoutStat++;
|
|
|
|
while ( SSP1SR & SSPSR_RNE ) // While not empty
|
|
{
|
|
receivedByte = SSP1DR;
|
|
xQueueSendToBackFromISR( ssp1DispatchedIsrQueue, &receivedByte, pdFALSE );
|
|
}
|
|
|
|
SSP1ICR = SSPICR_RTIC; /* clear interrupt */
|
|
}
|
|
|
|
/* please be aware that, in main and ISR, CurrentRxIndex and CurrentTxIndex
|
|
are shared as global variables. It may create some race condition that main
|
|
and ISR manipulate these variables at the same time. SSPSR_BSY checking (polling)
|
|
in both main and ISR could prevent this kind of race condition */
|
|
if ( regValue & SSPMIS_RXMIS ) /* Rx at least half full */
|
|
{
|
|
interruptRxStat++; /* receive until it's empty */
|
|
|
|
while ( SSP1SR & SSPSR_RNE ) // While not empty
|
|
{
|
|
receivedByte = SSP1DR;
|
|
xQueueSendToBackFromISR( ssp1DispatchedIsrQueue, &receivedByte, pdFALSE );
|
|
}
|
|
}
|
|
|
|
VICVectAddr = 0; /* Acknowledge Interrupt */
|
|
}
|
|
|