- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# analogin_isr.c

    00001 /*********************************************************************************
    00002
    00003  Copyright 2006-2008 MakingThings
    00004
    00005  Licensed under the Apache License,
    00006  Version 2.0 (the "License"); you may not use this file except in compliance
    00007  with the License. You may obtain a copy of the License at
    00008
    00009  http://www.apache.org/licenses/LICENSE-2.0
    00010
    00011  Unless required by applicable law or agreed to in writing, software distributed
    00012  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
    00013  CONDITIONS OF ANY KIND, either express or implied. See the License for
    00014  the specific language governing permissions and limitations under the License.
    00015
    00016 *********************************************************************************/
    00017
    00018 /*
    00019   BASIC INTERRUPT DRIVEN DRIVER FOR USB.
    00020
    00021   This file contains all the usb components that must be compiled
    00022   to ARM mode.  The components that can be compiled to either ARM or THUMB
    00023   mode are contained in analogin.C
    00024
    00025 */
    00026
    00027 /* Scheduler includes. */
    00028 #include "FreeRTOS.h"
    00029 #include "task.h"
    00030 #include "queue.h"
    00031 #include "semphr.h"
    00032
    00033 /* Demo application includes. */
    00034 #include "Board.h"
    00035
    00036 #include "analogin_internal.h"
    00037
    00038 /*-----------------------------------------------------------*/
    00039
    00040 extern struct AnalogIn_* AnalogIn;
    00041
    00042 /*-----------------------------------------------------------*/
    00043
    00044 /* The interrupt entry point is naked so we can control the context saving. */
    00045 void AnalogInIsr_Wrapper( void ) __attribute__ ((naked));
    00046
    00047 /* The interrupt handler function must be separate from the entry function
    00048 to ensure the correct stack frame is set up. */
    00049 void AnalogInIsr_Handler( void );
    00050
    00051 /*-----------------------------------------------------------*/
    00052
    00053
    00054 void AnalogInIsr_Handler( void )
    00055 {
    00056   portCHAR cTaskWokenByPost = pdFALSE;
    00057
    00058   int status = AT91C_BASE_ADC->ADC_SR;
    00059   if ( status & AT91C_ADC_DRDY )
    00060     cTaskWokenByPost = xSemaphoreGiveFromISR( AnalogIn->doneSemaphore, cTaskWokenByPost );
    00061
    00062   int value = AT91C_BASE_ADC->ADC_LCDR;
    00063   (void)value;
    00064
    00065   /* Clear AIC to complete ISR processing */
    00066   AT91C_BASE_AIC->AIC_EOICR = 0;
    00067
    00068   /* If a task was woken by either a frame being received then we may need to
    00069   switch to another task.  If the unblocked task was of higher priority then
    00070   the interrupted task it will then execute immediately that the ISR
    00071   completes. */
    00072   if( cTaskWokenByPost )
    00073   {
    00074     portYIELD_FROM_ISR();
    00075   }
    00076 }
    00077
    00078 void  AnalogInIsr_Wrapper( void )
    00079 {
    00080   /* Save the context of the interrupted task. */
    00081   portSAVE_CONTEXT();
    00082
    00083   /* Call the handler to do the work.  This must be a separate
    00084   function to ensure the stack frame is set up correctly. */
    00085   AnalogInIsr_Handler();
    00086
    00087   /* Restore the context of whichever task will execute next. */
    00088   portRESTORE_CONTEXT();
    00089 }
    00090

The Make Controller Kit is an open source project maintained by MakingThings.
MakingThings code is released under the Apache 2.0 license.
Bug tracker, development wiki and status can be found at http://dev.makingthings.com.
This document was last updated on 18 May 2009.