Mercurial > ecos
annotate packages/hal/common/current/tests/intr.c @ 10:d3fbcdfa1b2f ecos-sw-1999-05-29
Merge from eCos master repository on 1999-05-29-00:13:11-BST
| author | jlarmour |
|---|---|
| date | Fri, 28 May 1999 16:43:09 +0000 |
| parents | ece80412419a |
| children | 53104bbd5f99 |
| rev | line source |
|---|---|
| 0 | 1 /*================================================================= |
| 2 // | |
| 3 // intr.c | |
| 4 // | |
| 5 // HAL Interrupt API test | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 2 | 25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
| 0 | 26 // ------------------------------------------- |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //========================================================================== | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): nickg | |
| 33 // Contributors: nickg | |
| 34 // Date: 1998-10-08 | |
| 35 //####DESCRIPTIONEND#### | |
| 36 */ | |
| 37 | |
| 38 #include <pkgconf/hal.h> | |
| 39 | |
| 40 #include <cyg/infra/testcase.h> | |
| 41 | |
| 42 #include <cyg/hal/hal_intr.h> | |
| 43 | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
44 // Include HAL/Platform specifics |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
45 #include CYGBLD_HAL_PLATFORM_H |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
46 |
| 2 | 47 #ifdef CYGPKG_KERNEL |
| 48 #include <pkgconf/kernel.h> // Need to look for the RTC config. | |
| 0 | 49 #endif |
| 50 | |
|
8
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
51 // Fallback defaults (in case HAL didn't define these) |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
52 #ifndef CYGNUM_HAL_RTC_NUMERATOR |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
53 #define CYGNUM_HAL_RTC_NUMERATOR 1000000000 |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
54 #define CYGNUM_HAL_RTC_DENOMINATOR 100 |
|
ece80412419a
Merge from eCos master repository on 1999-05-21-22:05:54-BST
jlarmour
parents:
2
diff
changeset
|
55 #define CYGNUM_HAL_RTC_PERIOD 9999 |
| 0 | 56 #endif |
| 57 | |
| 58 // ------------------------------------------------------------------------- | |
| 59 | |
| 60 #define ISR_DATA 0xAAAA1234 | |
| 61 | |
| 62 // ------------------------------------------------------------------------- | |
| 63 | |
| 64 volatile cyg_count32 ticks = 0; | |
| 65 | |
| 66 // ------------------------------------------------------------------------- | |
| 67 | |
| 68 cyg_uint32 isr( cyg_uint32 vector, CYG_ADDRWORD data ) | |
| 69 { | |
| 70 CYG_TEST_CHECK( ISR_DATA == data , "Bad data passed to ISR"); | |
| 2 | 71 CYG_TEST_CHECK( CYGNUM_HAL_INTERRUPT_RTC == vector , |
| 72 "Bad vector passed to ISR"); | |
| 0 | 73 |
| 74 HAL_CLOCK_RESET( vector, CYGNUM_KERNEL_COUNTERS_RTC_PERIOD ); | |
| 75 | |
| 76 HAL_INTERRUPT_ACKNOWLEDGE( vector ); | |
| 77 | |
| 78 ticks++; | |
| 79 | |
| 80 return 0; | |
| 81 } | |
| 82 | |
| 83 // ------------------------------------------------------------------------- | |
| 84 | |
| 85 void intr_main( void ) | |
| 86 { | |
| 87 CYG_INTERRUPT_STATE oldints; | |
| 88 | |
| 2 | 89 HAL_INTERRUPT_ATTACH( CYGNUM_HAL_INTERRUPT_RTC, isr, ISR_DATA, 0 ); |
| 0 | 90 |
| 91 HAL_CLOCK_INITIALIZE( CYGNUM_KERNEL_COUNTERS_RTC_PERIOD ); | |
| 92 | |
| 2 | 93 HAL_INTERRUPT_UNMASK( CYGNUM_HAL_INTERRUPT_RTC ); |
| 0 | 94 |
| 95 HAL_ENABLE_INTERRUPTS(); | |
| 96 | |
| 97 while( ticks < 10 ) | |
| 98 { | |
| 99 | |
| 100 } | |
| 101 | |
| 102 HAL_DISABLE_INTERRUPTS(oldints); | |
| 103 | |
| 104 CYG_TEST_PASS_FINISH("HAL interrupt test"); | |
| 2 | 105 |
| 0 | 106 } |
| 107 | |
| 108 | |
| 109 // ------------------------------------------------------------------------- | |
| 110 | |
| 111 externC void | |
| 112 cyg_start( void ) | |
| 113 { | |
| 2 | 114 CYG_TEST_INIT(); |
| 115 | |
| 116 // Attaching the ISR will not succeed if the kernel real-time | |
| 117 // clock has been configured in. | |
| 118 #ifndef CYGVAR_KERNEL_COUNTERS_CLOCK | |
| 119 | |
| 0 | 120 intr_main(); |
| 2 | 121 |
| 122 #else | |
| 123 | |
| 124 CYG_TEST_PASS_FINISH("N/A: Cannot override kernel real-time clock."); | |
| 125 | |
| 126 #endif | |
| 0 | 127 } |
| 128 | |
| 129 | |
| 130 // ------------------------------------------------------------------------- | |
| 131 /* EOF intr.c */ |
