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 CAN BUS. 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 can.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 "can_internal.h" 00037 00038 /*-----------------------------------------------------------*/ 00039 00040 extern struct Can_ Can; 00041 00042 /*-----------------------------------------------------------*/ 00043 00044 /* The interrupt entry point is naked so we can control the context saving. */ 00045 void CanIsr_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 CanIsr_Handler( void ); 00050 00051 /*-----------------------------------------------------------*/ 00052 00053 00054 void CanIsr_Handler( void ) 00055 { 00056 portBASE_TYPE xSwitchRequired = pdFALSE; 00057 00058 // int status = AT91C_BASE_CAN->CAN_SR; 00059 /* 00060 if ( status & AT91C_ADC_DRDY ) 00061 cTaskWokenByPost = xSemaphoreGiveFromISR( Can.doneSemaphore, cTaskWokenByPost ); 00062 00063 int value = AT91C_BASE_ADC->ADC_LCDR; 00064 (void)value; 00065 */ 00066 /* Clear AIC to complete ISR processing */ 00067 AT91C_BASE_AIC->AIC_EOICR = 0; 00068 00069 /* If a task was woken by either a frame being received then we may need to 00070 switch to another task. If the unblocked task was of higher priority then 00071 the interrupted task it will then execute immediately that the ISR 00072 completes. */ 00073 if( xSwitchRequired ) 00074 { 00075 portYIELD_FROM_ISR(); 00076 } 00077 } 00078 00079 void CanIsr_Wrapper( void ) 00080 { 00081 /* Save the context of the interrupted task. */ 00082 portSAVE_CONTEXT(); 00083 00084 /* Call the handler to do the work. This must be a separate 00085 function to ensure the stack frame is set up correctly. */ 00086 CanIsr_Handler(); 00087 00088 /* Restore the context of whichever task will execute next. */ 00089 portRESTORE_CONTEXT(); 00090 } 00091
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.