Initial import, Timer v3.0

Fri, 13 Aug 2010 10:49:23 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Fri, 13 Aug 2010 10:49:23 +0100
changeset 0
396b0bd970d3
child 1
85c1144140c3

Initial import, Timer v3.0

document/ds_icon.jpg file | annotate | diff | revisions
document/ds_icon_ast.jpg file | annotate | diff | revisions
document/dsb_icon.jpg file | annotate | diff | revisions
document/lever40.css file | annotate | diff | revisions
document/lever40_ns.css file | annotate | diff | revisions
document/qm_icon.jpg file | annotate | diff | revisions
document/timer.htm file | annotate | diff | revisions
document/timer.pdf file | annotate | diff | revisions
drivers/device/MicoTimer.c file | annotate | diff | revisions
drivers/device/MicoTimer.h file | annotate | diff | revisions
drivers/peripheral.mk file | annotate | diff | revisions
drivers/service/MicoTimerService.c file | annotate | diff | revisions
drivers/service/MicoTimerService.h file | annotate | diff | revisions
rtl/verilog/timer.v file | annotate | diff | revisions
timer.xml file | annotate | diff | revisions
     1.1 Binary file document/ds_icon.jpg has changed
     2.1 Binary file document/ds_icon_ast.jpg has changed
     3.1 Binary file document/dsb_icon.jpg has changed
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/document/lever40.css	Fri Aug 13 10:49:23 2010 +0100
     4.3 @@ -0,0 +1,245 @@
     4.4 +H1 { 
     4.5 +    font-weight:bold; 
     4.6 +    border-top-style:none; 
     4.7 +    font-family:Arial, helvetica, sans-serif; 
     4.8 +    color:#ea6d23; 
     4.9 +    margin-left:15px; 
    4.10 +    margin-top:3px; 
    4.11 +    margin-bottom:10px; 
    4.12 +    border-bottom-style:Solid; 
    4.13 +    border-bottom-width:2px; 
    4.14 +    border-bottom-color:#dbdbdb; 
    4.15 +    margin-right:0px; 
    4.16 +    line-height:Normal; 
    4.17 +    font-size:1em;  }
    4.18 +LI.kadov-H1 { 
    4.19 +             font-weight:bold; 
    4.20 +             font-family:Arial, helvetica, sans-serif; 
    4.21 +             color:#ea6d23; 
    4.22 +             line-height:Normal; 
    4.23 +             font-size:1em;  }
    4.24 +H2 { 
    4.25 +    font-weight:bold; 
    4.26 +    x-text-underline:Off; 
    4.27 +    border-top-style:none; 
    4.28 +    border-bottom-style:none; 
    4.29 +    font-family:Arial, helvetica, sans-serif; 
    4.30 +    color:#ea6d23; 
    4.31 +    margin-left:15px; 
    4.32 +    margin-top:12px; 
    4.33 +    margin-bottom:5px; 
    4.34 +    font-size:0.84em; 
    4.35 +    margin-right:0px; 
    4.36 +    text-decoration:none;  }
    4.37 +LI.kadov-H2 { 
    4.38 +             font-weight:bold; 
    4.39 +             x-text-underline:Off; 
    4.40 +             font-family:Arial, helvetica, sans-serif; 
    4.41 +             color:#ea6d23; 
    4.42 +             font-size:0.84em; 
    4.43 +             text-decoration:none;  }
    4.44 +P { 
    4.45 +   margin-top:0pt; 
    4.46 +   font-family:Verdana, Arial, helvetica, sans-serif; 
    4.47 +   color:#323232; 
    4.48 +   font-size:71%; 
    4.49 +   margin-bottom:8px; 
    4.50 +   line-height:1.4em; 
    4.51 +   margin-right:0px; 
    4.52 +   margin-left:15px;  }
    4.53 +LI.kadov-P { 
    4.54 +            font-family:Verdana, Arial, helvetica, sans-serif; 
    4.55 +            color:#323232; 
    4.56 +            font-size:71%; 
    4.57 +            line-height:1.4em;  }
    4.58 +p.Step { 
    4.59 +        list-style:decimal; 
    4.60 +        margin-left:0px; 
    4.61 +        font-size:100%; 
    4.62 +        margin-bottom:7px; 
    4.63 +        margin-top:0px;  }
    4.64 +LI.kadov-p-CStep { 
    4.65 +                  list-style:decimal; 
    4.66 +                  font-size:100%;  }
    4.67 +P.Bullet { 
    4.68 +          font-size:100%; 
    4.69 +          list-style:url("image/top-bullet.gif"); 
    4.70 +          margin-bottom:7px; 
    4.71 +          margin-left:0px; 
    4.72 +          margin-top:0px;  }
    4.73 +LI.kadov-P-CBullet { 
    4.74 +                    font-size:100%; 
    4.75 +                    list-style:url("image/top-bullet.gif");  }
    4.76 +P.NormalIndent { 
    4.77 +                margin-left:40px;  }
    4.78 +LI.kadov-P-CNormalIndent {  }
    4.79 +P.BulletIndent { 
    4.80 +                margin-bottom:2px; 
    4.81 +                font-size:100%; 
    4.82 +                margin-left:15pt; 
    4.83 +                list-style:url("image/secondary-bullet.gif");  }
    4.84 +LI.kadov-P-CBulletIndent { 
    4.85 +                          font-size:100%; 
    4.86 +                          list-style:url("image/secondary-bullet.gif");  }
    4.87 +P.Procedure { 
    4.88 +             font-style:italic; 
    4.89 +             font-weight:normal; 
    4.90 +             x-next-class:Step; 
    4.91 +             x-next-type:p; 
    4.92 +             margin-top:12pt; 
    4.93 +             margin-bottom:5px;  }
    4.94 +LI.kadov-P-CProcedure { 
    4.95 +                       font-style:italic; 
    4.96 +                       font-weight:normal;  }
    4.97 +P.Note { 
    4.98 +        margin-top:8pt; 
    4.99 +        margin-bottom:8pt; 
   4.100 +        border-top-style:Solid; 
   4.101 +        border-bottom-style:Solid; 
   4.102 +        padding-top:4px; 
   4.103 +        padding-bottom:4px; 
   4.104 +        border-top-width:1px; 
   4.105 +        border-bottom-width:1px; 
   4.106 +        background-color:#ffffff;  }
   4.107 +LI.kadov-P-CNote {  }
   4.108 +P.NoteIndent { 
   4.109 +              margin-top:8pt; 
   4.110 +              margin-bottom:8pt; 
   4.111 +              border-top-style:Solid; 
   4.112 +              border-bottom-style:Solid; 
   4.113 +              padding-top:4px; 
   4.114 +              padding-bottom:4px; 
   4.115 +              border-top-width:1px; 
   4.116 +              border-bottom-width:1px; 
   4.117 +              background-color:#ffffff; 
   4.118 +              margin-left:40px;  }
   4.119 +LI.kadov-P-CNoteIndent {  }
   4.120 +P.Table { 
   4.121 +         margin-top:4px; 
   4.122 +         margin-bottom:4px; 
   4.123 +         margin-right:4px; 
   4.124 +         margin-left:4px;  }
   4.125 +LI.kadov-P-CTable {  }
   4.126 +P.Code { 
   4.127 +        margin-bottom:0px; 
   4.128 +        line-height:Normal; 
   4.129 +        font-family:"Courier New"  , Courier, monospace;  }
   4.130 +LI.kadov-P-CCode { 
   4.131 +                  line-height:Normal; 
   4.132 +                  font-family:"Courier New"  , Courier, monospace;  }
   4.133 +P.StepBulletFirst { 
   4.134 +                   font-size:100%; 
   4.135 +                   margin-left:15px; 
   4.136 +                   margin-bottom:2px; 
   4.137 +                   list-style:url("image/secondary-bullet.gif");  }
   4.138 +LI.kadov-P-CStepBulletFirst { 
   4.139 +                             font-size:100%; 
   4.140 +                             list-style:url("image/secondary-bullet.gif");  }
   4.141 +BODY { 
   4.142 +      background-color:#ffffff; 
   4.143 +      color:#000080; 
   4.144 +      font-family:Arial, sans-serif;  }
   4.145 +P.SeeAlso { 
   4.146 +           font-weight:bold; 
   4.147 +           font-style:normal; 
   4.148 +           x-next-type:P; 
   4.149 +           color:#ea6d23; 
   4.150 +           font-family:Arial, helvetica, sans-serif; 
   4.151 +           margin-left:15px; 
   4.152 +           margin-top:12px; 
   4.153 +           margin-bottom:5px; 
   4.154 +           font-size:0.84em;  }
   4.155 +LI.kadov-P-CSeeAlso { 
   4.156 +                     font-weight:bold; 
   4.157 +                     font-style:normal; 
   4.158 +                     color:#ea6d23; 
   4.159 +                     font-family:Arial, helvetica, sans-serif; 
   4.160 +                     font-size:0.84em;  }
   4.161 +A:link { 
   4.162 +        font-weight:bold; 
   4.163 +        font-style:normal; 
   4.164 +        color:#003a98; 
   4.165 +        x-text-underline:Off; 
   4.166 +        text-decoration:none;  }
   4.167 +A:hover { 
   4.168 +         x-text-underline:Normal; 
   4.169 +         color:#59add3; 
   4.170 +         text-decoration:underline;  }
   4.171 +A:active { 
   4.172 +          color:#59add3;  }
   4.173 +A:visited { 
   4.174 +           x-text-underline:Off; 
   4.175 +           color:#385689; 
   4.176 +           font-weight:bold; 
   4.177 +           font-style:normal; 
   4.178 +           text-decoration:none;  }
   4.179 +H1.Home { 
   4.180 +         x-next-type:P; 
   4.181 +         border-top-style:none; 
   4.182 +         border-bottom-style:none; 
   4.183 +         x-text-underline:Off; 
   4.184 +         font-size:15pt; 
   4.185 +         color:#ea6d23; 
   4.186 +         text-decoration:none;  }
   4.187 +LI.kadov-H1-CHome { 
   4.188 +                   x-text-underline:Off; 
   4.189 +                   font-size:15pt; 
   4.190 +                   color:#ea6d23; 
   4.191 +                   text-decoration:none;  }
   4.192 +H3 { 
   4.193 +    margin-left:15px; 
   4.194 +    margin-top:12px; 
   4.195 +    margin-bottom:5px; 
   4.196 +    color:#323232; 
   4.197 +    font-size:71%; 
   4.198 +    font-family:Verdana, Arial, helvetica, sans-serif; 
   4.199 +    margin-right:0px;  }
   4.200 +LI.kadov-H3 { 
   4.201 +             color:#323232; 
   4.202 +             font-size:71%; 
   4.203 +             font-family:Verdana, Arial, helvetica, sans-serif;  }
   4.204 +P.Title { 
   4.205 +         font-weight:bold; 
   4.206 +         font-style:normal; 
   4.207 +         x-next-type:P; 
   4.208 +         font-family:Arial, helvetica, sans-serif; 
   4.209 +         color:#ea6d23; 
   4.210 +         margin-bottom:10px; 
   4.211 +         font-size:1.4em; 
   4.212 +         line-height:Normal; 
   4.213 +         border-bottom-style:Solid; 
   4.214 +         border-bottom-width:2px; 
   4.215 +         border-bottom-color:#dbdbdb; 
   4.216 +         margin-top:0px;  }
   4.217 +LI.kadov-P-CTitle { 
   4.218 +                   font-weight:bold; 
   4.219 +                   font-style:normal; 
   4.220 +                   font-family:Arial, helvetica, sans-serif; 
   4.221 +                   color:#ea6d23; 
   4.222 +                   font-size:1.4em; 
   4.223 +                   line-height:Normal;  }
   4.224 +P.Supra { 
   4.225 +         font-weight:bold; 
   4.226 +         font-style:normal; 
   4.227 +         margin-bottom:6pt; 
   4.228 +         font-family:Arial, helvetica, sans-serif;  }
   4.229 +LI.kadov-P-CSupra { 
   4.230 +                   font-weight:bold; 
   4.231 +                   font-style:normal; 
   4.232 +                   font-family:Arial, helvetica, sans-serif;  }
   4.233 +OL { 
   4.234 +    font-size:71%; 
   4.235 +    font-family:Verdana, Arial, helvetica, sans-serif; 
   4.236 +    color:#323232;  }
   4.237 +UL { 
   4.238 +    font-size:71%; 
   4.239 +    font-family:Verdana, Arial, helvetica, sans-serif; 
   4.240 +    color:#323232;  }
   4.241 +P.CodeIndent { 
   4.242 +              font-family:"Courier New"  , Courier, monospace; 
   4.243 +              margin-left:40px; 
   4.244 +              margin-bottom:0px; 
   4.245 +              line-height:Normal;  }
   4.246 +LI.kadov-P-CCodeIndent { 
   4.247 +                        font-family:"Courier New"  , Courier, monospace; 
   4.248 +                        line-height:Normal;  }
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/document/lever40_ns.css	Fri Aug 13 10:49:23 2010 +0100
     5.3 @@ -0,0 +1,248 @@
     5.4 +H1 { 
     5.5 +    font-weight:bold; 
     5.6 +    border-top-style:none; 
     5.7 +    font-family:Arial, helvetica, sans-serif; 
     5.8 +    color:#ea6d23; 
     5.9 +    margin-left:15px; 
    5.10 +    margin-top:3px; 
    5.11 +    margin-bottom:10px; 
    5.12 +    border-bottom-style:Solid; 
    5.13 +    border-bottom-width:2px; 
    5.14 +    border-bottom-color:#dbdbdb; 
    5.15 +    margin-right:1pt; 
    5.16 +    line-height:Normal; 
    5.17 +    font-size:1em;  }
    5.18 +LI.kadov-H1 { 
    5.19 +             font-weight:bold; 
    5.20 +             font-family:Arial, helvetica, sans-serif; 
    5.21 +             color:#ea6d23; 
    5.22 +             line-height:Normal; 
    5.23 +             font-size:1em;  }
    5.24 +H2 { 
    5.25 +    font-weight:bold; 
    5.26 +    x-text-underline:Off; 
    5.27 +    border-top-style:none; 
    5.28 +    border-bottom-style:none; 
    5.29 +    font-family:Arial, helvetica, sans-serif; 
    5.30 +    color:#ea6d23; 
    5.31 +    margin-left:15px; 
    5.32 +    margin-top:12px; 
    5.33 +    margin-bottom:5px; 
    5.34 +    font-size:0.84em; 
    5.35 +    margin-right:1pt; 
    5.36 +    text-decoration:none;  }
    5.37 +LI.kadov-H2 { 
    5.38 +             font-weight:bold; 
    5.39 +             x-text-underline:Off; 
    5.40 +             font-family:Arial, helvetica, sans-serif; 
    5.41 +             color:#ea6d23; 
    5.42 +             font-size:0.84em; 
    5.43 +             text-decoration:none;  }
    5.44 +P { 
    5.45 +   margin-top:1pt; 
    5.46 +   font-family:Verdana, Arial, helvetica, sans-serif; 
    5.47 +   color:#323232; 
    5.48 +   font-size:71%; 
    5.49 +   margin-bottom:8px; 
    5.50 +   line-height:1.4em; 
    5.51 +   margin-right:1pt; 
    5.52 +   margin-left:15px;  }
    5.53 +LI.kadov-P { 
    5.54 +            font-family:Verdana, Arial, helvetica, sans-serif; 
    5.55 +            color:#323232; 
    5.56 +            font-size:71%; 
    5.57 +            line-height:1.4em;  }
    5.58 +p.Step { 
    5.59 +        list-style:decimal; 
    5.60 +        margin-left:1pt; 
    5.61 +        font-size:100%; 
    5.62 +        margin-bottom:7px; 
    5.63 +        margin-top:1pt;  }
    5.64 +LI.kadov-p-CStep { 
    5.65 +                  list-style:decimal; 
    5.66 +                  font-size:100%;  }
    5.67 +P.Bullet { 
    5.68 +          font-size:100%; 
    5.69 +          margin-bottom:7px; 
    5.70 +          margin-left:1pt; 
    5.71 +          margin-top:1pt;  }
    5.72 +LI.kadov-P-CBullet { 
    5.73 +                    font-size:100%;  }
    5.74 +P.NormalIndent { 
    5.75 +                margin-left:40px;  }
    5.76 +LI.kadov-P-CNormalIndent {  }
    5.77 +P.BulletIndent { 
    5.78 +                margin-bottom:2px; 
    5.79 +                font-size:100%; 
    5.80 +                margin-left:15pt;  }
    5.81 +LI.kadov-P-CBulletIndent { 
    5.82 +                          font-size:100%;  }
    5.83 +P.Procedure { 
    5.84 +             font-style:italic; 
    5.85 +             font-weight:normal; 
    5.86 +             x-next-class:Step; 
    5.87 +             x-next-type:p; 
    5.88 +             margin-top:12pt; 
    5.89 +             margin-bottom:5px;  }
    5.90 +LI.kadov-P-CProcedure { 
    5.91 +                       font-style:italic; 
    5.92 +                       font-weight:normal;  }
    5.93 +P.Note { 
    5.94 +        margin-top:8pt; 
    5.95 +        margin-bottom:8pt; 
    5.96 +        border-top-style:Solid; 
    5.97 +        border-bottom-style:Solid; 
    5.98 +        padding-top:4px; 
    5.99 +        padding-bottom:4px; 
   5.100 +        border-top-width:1px; 
   5.101 +        border-bottom-width:1px; 
   5.102 +        background-color:#ffffff;  }
   5.103 +LI.kadov-P-CNote {  }
   5.104 +P.NoteIndent { 
   5.105 +              margin-top:8pt; 
   5.106 +              margin-bottom:8pt; 
   5.107 +              border-top-style:Solid; 
   5.108 +              border-bottom-style:Solid; 
   5.109 +              padding-top:4px; 
   5.110 +              padding-bottom:4px; 
   5.111 +              border-top-width:1px; 
   5.112 +              border-bottom-width:1px; 
   5.113 +              background-color:#ffffff; 
   5.114 +              margin-left:40px;  }
   5.115 +LI.kadov-P-CNoteIndent {  }
   5.116 +P.Table { 
   5.117 +         margin-top:4px; 
   5.118 +         margin-bottom:4px; 
   5.119 +         margin-right:4px; 
   5.120 +         margin-left:4px;  }
   5.121 +LI.kadov-P-CTable {  }
   5.122 +P.Code { 
   5.123 +        margin-bottom:1pt; 
   5.124 +        line-height:Normal; 
   5.125 +        font-family:"Courier New"     , Courier, monospace;  }
   5.126 +LI.kadov-P-CCode { 
   5.127 +                  line-height:Normal; 
   5.128 +                  font-family:"Courier New"     , Courier, monospace;  }
   5.129 +P.StepBulletFirst { 
   5.130 +                   font-size:100%; 
   5.131 +                   margin-left:15px; 
   5.132 +                   margin-bottom:2px;  }
   5.133 +LI.kadov-P-CStepBulletFirst { 
   5.134 +                             font-size:100%;  }
   5.135 +BODY { 
   5.136 +      background-color:#ffffff; 
   5.137 +      color:#000080; 
   5.138 +      font-family:Arial, sans-serif;  }
   5.139 +P.SeeAlso { 
   5.140 +           font-weight:bold; 
   5.141 +           font-style:normal; 
   5.142 +           x-next-type:P; 
   5.143 +           color:#ea6d23; 
   5.144 +           font-family:Arial, helvetica, sans-serif; 
   5.145 +           margin-left:15px; 
   5.146 +           margin-top:12px; 
   5.147 +           margin-bottom:5px; 
   5.148 +           font-size:0.84em;  }
   5.149 +LI.kadov-P-CSeeAlso { 
   5.150 +                     font-weight:bold; 
   5.151 +                     font-style:normal; 
   5.152 +                     color:#ea6d23; 
   5.153 +                     font-family:Arial, helvetica, sans-serif; 
   5.154 +                     font-size:0.84em;  }
   5.155 +A:link { 
   5.156 +        font-weight:bold; 
   5.157 +        font-style:normal; 
   5.158 +        color:#003a98; 
   5.159 +        x-text-underline:Off; 
   5.160 +        text-decoration:none;  }
   5.161 +A:hover { 
   5.162 +         x-text-underline:Normal; 
   5.163 +         color:#59add3; 
   5.164 +         text-decoration:underline;  }
   5.165 +A:active { 
   5.166 +          color:#59add3;  }
   5.167 +A:visited { 
   5.168 +           x-text-underline:Off; 
   5.169 +           color:#385689; 
   5.170 +           font-weight:bold; 
   5.171 +           font-style:normal; 
   5.172 +           text-decoration:none;  }
   5.173 +H1.Home { 
   5.174 +         x-next-type:P; 
   5.175 +         border-top-style:none; 
   5.176 +         border-bottom-style:none; 
   5.177 +         x-text-underline:Off; 
   5.178 +         font-size:15pt; 
   5.179 +         color:#ea6d23; 
   5.180 +         text-decoration:none;  }
   5.181 +LI.kadov-H1-CHome { 
   5.182 +                   x-text-underline:Off; 
   5.183 +                   font-size:15pt; 
   5.184 +                   color:#ea6d23; 
   5.185 +                   text-decoration:none;  }
   5.186 +H3 { 
   5.187 +    margin-left:15px; 
   5.188 +    margin-top:12px; 
   5.189 +    margin-bottom:5px; 
   5.190 +    color:#323232; 
   5.191 +    font-size:71%; 
   5.192 +    font-family:Verdana, Arial, helvetica, sans-serif; 
   5.193 +    margin-right:1pt; 
   5.194 +    font-weight:bold;  }
   5.195 +LI.kadov-H3 { 
   5.196 +             color:#323232; 
   5.197 +             font-size:71%; 
   5.198 +             font-family:Verdana, Arial, helvetica, sans-serif;  }
   5.199 +P.Title { 
   5.200 +         font-weight:bold; 
   5.201 +         font-style:normal; 
   5.202 +         x-next-type:P; 
   5.203 +         font-family:Arial, helvetica, sans-serif; 
   5.204 +         color:#ea6d23; 
   5.205 +         margin-bottom:10px; 
   5.206 +         font-size:1.4em; 
   5.207 +         line-height:Normal; 
   5.208 +         border-bottom-style:Solid; 
   5.209 +         border-bottom-width:2px; 
   5.210 +         border-bottom-color:#dbdbdb; 
   5.211 +         margin-top:1pt;  }
   5.212 +LI.kadov-P-CTitle { 
   5.213 +                   font-weight:bold; 
   5.214 +                   font-style:normal; 
   5.215 +                   font-family:Arial, helvetica, sans-serif; 
   5.216 +                   color:#ea6d23; 
   5.217 +                   font-size:1.4em; 
   5.218 +                   line-height:Normal;  }
   5.219 +P.Supra { 
   5.220 +         font-weight:bold; 
   5.221 +         font-style:normal; 
   5.222 +         margin-bottom:6pt; 
   5.223 +         font-family:Arial, helvetica, sans-serif;  }
   5.224 +LI.kadov-P-CSupra { 
   5.225 +                   font-weight:bold; 
   5.226 +                   font-style:normal; 
   5.227 +                   font-family:Arial, helvetica, sans-serif;  }
   5.228 +OL { 
   5.229 +    font-size:71%; 
   5.230 +    font-family:Verdana, Arial, helvetica, sans-serif; 
   5.231 +    color:#323232;  }
   5.232 +UL { 
   5.233 +    font-size:71%; 
   5.234 +    font-family:Verdana, Arial, helvetica, sans-serif; 
   5.235 +    color:#323232;  }
   5.236 +P.CodeIndent { 
   5.237 +              font-family:"Courier New"     , Courier, monospace; 
   5.238 +              margin-left:40px; 
   5.239 +              margin-bottom:1pt; 
   5.240 +              line-height:Normal;  }
   5.241 +LI.kadov-P-CCodeIndent { 
   5.242 +                        font-family:"Courier New"     , Courier, monospace; 
   5.243 +                        line-height:Normal;  }
   5.244 +ol ol { 
   5.245 +       margin-top:1px;  }
   5.246 +ol ul { 
   5.247 +       margin-top:1px;  }
   5.248 +ul ul { 
   5.249 +       margin-top:1px;  }
   5.250 +ul ol { 
   5.251 +       margin-top:1px;  }
     6.1 Binary file document/qm_icon.jpg has changed
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/document/timer.htm	Fri Aug 13 10:49:23 2010 +0100
     7.3 @@ -0,0 +1,253 @@
     7.4 +<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
     7.5 +
     7.6 +<html>
     7.7 +
     7.8 +<head>
     7.9 +<title>timer</title>
    7.10 +<meta http-equiv="content-type" content="text/html; charset=windows-1252">
    7.11 +<meta name="generator" content="RoboHelp by eHelp Corporation www.ehelp.com">
    7.12 +<link rel="stylesheet" href="lever40_ns.css"><script type="text/javascript" language="JavaScript" title="WebHelpSplitCss">
    7.13 +<!--
    7.14 +if (navigator.appName !="Netscape")
    7.15 +{   document.write("<link rel='stylesheet' href='lever40.css'>");}
    7.16 +//-->
    7.17 +</script>
    7.18 +<style type="text/css">
    7.19 +<!--
    7.20 +img_whs1 { border:none; width:29px; height:31px; float:none; border-style:none; }
    7.21 +p.whs2 { font-style:italic; }
    7.22 +table.whs3 { x-cell-content-align:top; height:84px; margin-left:14px; left:0px; top:114px; width:636px; border-spacing:0px; }
    7.23 +col.whs4 { width:87px; }
    7.24 +col.whs5 { width:502px; }
    7.25 +tr.whs6 { x-cell-content-align:top; height:22px; }
    7.26 +td.whs7 { width:87px; padding-right:10px; padding-left:10px; border-left-style:Solid; border-left-color:#c0c0c0; border-top-style:Solid; border-top-color:#c0c0c0; border-right-color:#c0c0c0; border-right-style:Solid; border-bottom-color:#c0c0c0; border-bottom-style:Solid; border-right-width:1px; border-left-width:1px; border-top-width:1px; border-bottom-width:1px; background-color:#dee8f4; }
    7.27 +td.whs8 { width:502px; padding-right:10px; padding-left:10px; border-top-style:Solid; border-top-color:#c0c0c0; border-right-color:#c0c0c0; border-right-style:Solid; border-bottom-color:#c0c0c0; border-bottom-style:Solid; border-top-width:1px; border-bottom-width:1px; border-right-width:1px; background-color:#dee8f4; }
    7.28 +td.whs9 { width:87px; padding-right:10px; padding-left:10px; border-left-color:#c0c0c0; border-left-width:1px; border-left-style:Solid; border-right-color:#c0c0c0; border-right-style:Solid; border-right-width:1px; border-bottom-color:#c0c0c0; border-bottom-style:Solid; border-bottom-width:1px; }
    7.29 +td.whs10 { width:502px; padding-right:10px; padding-left:10px; border-right-color:#c0c0c0; border-right-style:Solid; border-right-width:1px; border-bottom-color:#c0c0c0; border-bottom-style:Solid; border-bottom-width:1px; }
    7.30 +p.whs11 { margin-left:4px; }
    7.31 +table.whs12 { x-cell-content-align:top; margin-left:15px; border-spacing:0px; }
    7.32 +col.whs13 { width:86px; }
    7.33 +tr.whs14 { x-cell-content-align:top; }
    7.34 +td.whs15 { width:86px; padding-right:10px; padding-left:10px; border-left-style:Solid; border-left-color:#c0c0c0; border-top-color:#c0c0c0; border-top-style:Solid; border-right-color:#c0c0c0; border-right-style:Solid; border-bottom-color:#c0c0c0; border-bottom-style:Solid; border-right-width:1px; border-left-width:1px; border-top-width:1px; border-bottom-width:1px; background-color:#dee8f4; }
    7.35 +td.whs16 { width:502px; padding-right:10px; padding-left:10px; border-top-color:#c0c0c0; border-top-style:Solid; border-right-color:#c0c0c0; border-right-style:Solid; border-bottom-color:#c0c0c0; border-bottom-style:Solid; border-top-width:1px; border-bottom-width:1px; border-right-width:1px; background-color:#dee8f4; }
    7.36 +td.whs17 { width:86px; padding-right:10px; padding-left:10px; border-left-style:Solid; border-left-width:1px; border-left-color:#c0c0c0; border-right-width:1px; border-right-color:#c0c0c0; border-right-style:Solid; border-bottom-width:1px; border-bottom-color:#c0c0c0; border-bottom-style:Solid; }
    7.37 +td.whs18 { width:502px; padding-right:10px; padding-left:10px; border-right-width:1px; border-right-color:#c0c0c0; border-right-style:Solid; border-bottom-width:1px; border-bottom-color:#c0c0c0; border-bottom-style:Solid; }
    7.38 +td.whs19 { width:86px; padding-right:10px; padding-left:10px; border-left-color:#c0c0c0; border-left-width:1px; border-left-style:Solid; border-right-style:Solid; border-right-color:#c0c0c0; border-right-width:1px; border-bottom-style:Solid; border-bottom-color:#c0c0c0; border-bottom-width:1px; }
    7.39 +td.whs20 { width:502px; padding-right:10px; padding-left:10px; border-right-style:Solid; border-right-color:#c0c0c0; border-right-width:1px; border-bottom-style:Solid; border-bottom-color:#c0c0c0; border-bottom-width:1px; }
    7.40 +img_whs21 { border:none; width:14px; height:16px; float:none; border-style:none; }
    7.41 +-->
    7.42 +</style><script type="text/javascript" language="JavaScript">
    7.43 +<!--
    7.44 +function ehlp_showtip(current,e,text)
    7.45 +{
    7.46 +  if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == 'Netscape'))
    7.47 +  {
    7.48 +    document.tooltip.document.write("<layer bgColor='yellow' style='border:1px solid black;font-size:12px;'>"+ text + "</layer>");
    7.49 +    document.tooltip.document.close();
    7.50 +    document.tooltip.left=e.pageX+5;
    7.51 +    document.tooltip.top=e.pageY+5;
    7.52 +    document.tooltip.visibility="show";
    7.53 +  }
    7.54 +}
    7.55 +function ehlp_hidetip()
    7.56 +{
    7.57 +  document.tooltip.visibility="hidden";
    7.58 +}
    7.59 +//-->
    7.60 +</script>
    7.61 +<script type="text/javascript" language="JavaScript" title="WebHelpInlineScript">
    7.62 +<!--
    7.63 +function reDo() {
    7.64 +  if (innerWidth != origWidth || innerHeight != origHeight)
    7.65 +     location.reload();
    7.66 +}
    7.67 +if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == "Netscape")) {
    7.68 +	origWidth = innerWidth;
    7.69 +	origHeight = innerHeight;
    7.70 +	onresize = reDo;
    7.71 +}
    7.72 +onerror = null; 
    7.73 +//-->
    7.74 +</script>
    7.75 +<style type="text/css">
    7.76 +<!--
    7.77 +div.WebHelpPopupMenu { position:absolute; left:0px; top:0px; z-index:4; visibility:hidden; }
    7.78 +p.WebHelpNavBar { text-align:right; }
    7.79 +-->
    7.80 +</style><script type="text/javascript" language="javascript1.2" src="whmsg.js"></script>
    7.81 +<script type="text/javascript" language="javascript" src="whver.js"></script>
    7.82 +<script type="text/javascript" language="javascript1.2" src="whproxy.js"></script>
    7.83 +<script type="text/javascript" language="javascript1.2" src="whutils.js"></script>
    7.84 +<script type="text/javascript" language="javascript1.2" src="whtopic.js"></script>
    7.85 +<script type="text/javascript" language="javascript1.2">
    7.86 +<!--
    7.87 +if (window.gbWhTopic)
    7.88 +{
    7.89 +	if (window.setRelStartPage)
    7.90 +	{
    7.91 +	addTocInfo("Timer");
    7.92 +
    7.93 +	}
    7.94 +
    7.95 +
    7.96 +	if (window.setRelStartPage)
    7.97 +	{
    7.98 +	setRelStartPage("msb_peripherals.htm");
    7.99 +
   7.100 +		autoSync(0);
   7.101 +		sendSyncInfo();
   7.102 +		sendAveInfoOut();
   7.103 +	}
   7.104 +
   7.105 +}
   7.106 +else
   7.107 +	if (window.gbIE4)
   7.108 +		document.location.reload();
   7.109 +//-->
   7.110 +</script>
   7.111 +</head>
   7.112 +<body><script type="text/javascript" language="javascript1.2">
   7.113 +<!--
   7.114 +if (window.writeIntopicBar)
   7.115 +	writeIntopicBar(4);
   7.116 +//-->
   7.117 +</script>
   7.118 +<h1>LatticeMico32 Timer &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a title="View Data Sheet" href="timer.pdf" target="_blank" onmouseover="if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == 'Netscape')) ehlp_showtip(this,event,'View Data Sheet');" onmouseout="if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == 'Netscape')) ehlp_hidetip();"><img src="ds_icon_ast.jpg" x-maintain-ratio="TRUE" width="29px" height="31px" border="0" class="img_whs1"></a></h1>
   7.119 +
   7.120 +<p>The LatticeMico32 timer is a highly configurable countdown timer with 
   7.121 + a WISHBONE-compliant slave interface compatible with the LatticeMico32 
   7.122 + microprocessor. &nbsp;</p>
   7.123 +
   7.124 +<p class="whs2"><span style="font-style: italic;"><I>*If the 
   7.125 + data sheet fails to open, see the note at the bottom of this page.</I></span></p>
   7.126 +
   7.127 +<h2>Revision History</h2>
   7.128 +
   7.129 +<table x-use-null-cells cellspacing="0" width="636" height="84" class="whs3">
   7.130 +<script language='JavaScript'><!--
   7.131 +if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4)) document.write("</table><table x-use-null-cells cellspacing='0' width='636' height='84' border='1' bordercolor='silver' bordercolorlight='silver' bordercolordark='silver'>");
   7.132 +//--></script>
   7.133 +<col class="whs4">
   7.134 +<col class="whs5">
   7.135 +
   7.136 +<tr valign="top" class="whs6">
   7.137 +<td bgcolor="#DEE8F4" width="87px" class="whs7">
   7.138 +<p class=Table
   7.139 +	style="font-weight: bold;">Version</td>
   7.140 +<td bgcolor="#DEE8F4" width="502px" class="whs8">
   7.141 +<p class=Table
   7.142 +	style="font-weight: bold;">Description</td></tr>
   7.143 +
   7.144 +<tr valign="top" class="whs6">
   7.145 +<td colspan="1" rowspan="1" width="87px" class="whs9">
   7.146 +<p class=Table
   7.147 +	style="font-weight: normal;"><span style="font-weight: normal;">3.0 
   7.148 + (7.0 SP2)</span></td>
   7.149 +<td colspan="1" rowspan="1" width="502px" class="whs10">
   7.150 +<p class=Table>Version number change only. No RTL code change.</td></tr>
   7.151 +
   7.152 +<tr valign="top" class="whs6">
   7.153 +<td colspan="1" rowspan="1" width="87px" class="whs9">
   7.154 +<p class="whs11">1.0</td>
   7.155 +<td colspan="1" rowspan="1" width="502px" class="whs10">
   7.156 +<p class=Table>Initial release.</td></tr>
   7.157 +<script language='JavaScript'><!--
   7.158 +if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4)) document.write("</table></table><table>");
   7.159 +//--></script>
   7.160 +</table>
   7.161 +
   7.162 +&nbsp; 
   7.163 +
   7.164 +<h2>Dialog Box Parameters</h2>
   7.165 +
   7.166 +<table x-use-null-cells cellspacing="0" class="whs12">
   7.167 +<script language='JavaScript'><!--
   7.168 +if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4)) document.write("</table><table x-use-null-cells cellspacing='0' border='1' bordercolor='silver' bordercolorlight='silver' bordercolordark='silver'>");
   7.169 +//--></script>
   7.170 +<col class="whs13">
   7.171 +<col class="whs5">
   7.172 +
   7.173 +<tr valign="top" class="whs14">
   7.174 +<td bgcolor="#DEE8F4" width="86px" class="whs15">
   7.175 +<p class=Table
   7.176 +	style="font-weight: bold;">Property</td>
   7.177 +<td bgcolor="#DEE8F4" width="502px" class="whs16">
   7.178 +<p class=Table
   7.179 +	style="font-weight: bold;">Description</td></tr>
   7.180 +
   7.181 +<tr valign="top" class="whs14">
   7.182 +<td colspan="1" rowspan="1" width="86px" class="whs17">
   7.183 +<p class=Table>Instance Name</td>
   7.184 +<td colspan="1" rowspan="1" width="502px" class="whs18">
   7.185 +<p class=Table>Specifies the name of the timer instance. Alphanumeric values 
   7.186 + and underscores are supported. The default is timer.</td></tr>
   7.187 +
   7.188 +<tr valign="top" class="whs14">
   7.189 +<td width="86px" class="whs17">
   7.190 +<p class=Table>Base Address</td>
   7.191 +<td width="502px" class="whs18">
   7.192 +<p class=Table>Specifies the base address for configuring the timer device. 
   7.193 + The minimum boundary alignment is 0X80. Supported &nbsp;values 
   7.194 + are 0X00000000 to 0XFFFFFFFF. The default is 0X00000000.</td></tr>
   7.195 +
   7.196 +<tr valign="top" class="whs14">
   7.197 +<td colspan="1" rowspan="1" width="86px" class="whs17">
   7.198 +<p class=Table>Writeable Tick Count</td>
   7.199 +<td colspan="1" rowspan="1" width="502px" class="whs18">
   7.200 +<p class=Table>Determines whether the period register is writable. A tick 
   7.201 + is equivalent to one clock cycle. This option is selected by default.</td></tr>
   7.202 +
   7.203 +<tr valign="top" class="whs14">
   7.204 +<td colspan="1" rowspan="1" width="86px" class="whs17">
   7.205 +<p class=Table>Readable Tick Count</td>
   7.206 +<td colspan="1" rowspan="1" width="502px" class="whs18">
   7.207 +<p class=Table>Determines whether the snapshot register is readable. This 
   7.208 + option is selected by default.</td></tr>
   7.209 +
   7.210 +<tr valign="top" class="whs14">
   7.211 +<td colspan="1" rowspan="1" width="86px" class="whs17">
   7.212 +<p class=Table>Start Stop Control</td>
   7.213 +<td colspan="1" rowspan="1" width="502px" class="whs18">
   7.214 +<p class=Table>Determines whether the START and STOP bits are controllable. 
   7.215 + This option is selected by default.</td></tr>
   7.216 +
   7.217 +<tr valign="top" class="whs14">
   7.218 +<td colspan="1" rowspan="1" width="86px" class="whs19">
   7.219 +<p class=Table>Default Reload Ticks</td>
   7.220 +<td colspan="1" rowspan="1" width="502px" class="whs20">
   7.221 +<p class=Table>Specifies the initial countdown value. The period number 
   7.222 + is the reload value used to initialize the counter. The value should be 
   7.223 + in the range that can be represented by the period width. Supported values 
   7.224 + are 0X00000000 to 0XFFFFFFFF. The default is 20 (0X14).</td></tr>
   7.225 +
   7.226 +<tr valign="top" class="whs14">
   7.227 +<td colspan="1" rowspan="1" width="86px" class="whs17">
   7.228 +<p class=Table>Counter Width</td>
   7.229 +<td colspan="1" rowspan="1" width="502px" class="whs18">
   7.230 +<p class=Table>Controls the period register and internal counter's width. 
   7.231 + The period width is the width of the adder-subtractor used to implement 
   7.232 + the counter. Supported values are 1 to 31. The default is 32.</td></tr>
   7.233 +<script language='JavaScript'><!--
   7.234 +if ((navigator.appName == "Netscape") && (parseInt(navigator.appVersion) == 4)) document.write("</table></table><table>");
   7.235 +//--></script>
   7.236 +</table>
   7.237 +
   7.238 +&nbsp; 
   7.239 +
   7.240 +<p><span style="font-weight: bold;"><B>Note</B></span>: If the data sheet fails 
   7.241 + to open, click <img src="qm_icon.jpg" x-maintain-ratio="TRUE" width="14px" height="16px" border="0" class="img_whs21"> on the Available Components toolbar, and 
   7.242 + then click the note button.</p>
   7.243 +
   7.244 +<script type="text/javascript" language="JavaScript">
   7.245 +<!--
   7.246 + if ((parseInt(navigator.appVersion) == 4) && (navigator.appName == 'Netscape'))
   7.247 +  document.write("<div id='tooltip' class='WebHelpPopupMenu'></div>");
   7.248 +//-->
   7.249 +</script><script type="text/javascript" language="javascript1.2">
   7.250 +<!--
   7.251 +if (window.writeIntopicBar)
   7.252 +	writeIntopicBar(0);
   7.253 +//-->
   7.254 +</script>
   7.255 +</body>
   7.256 +</html>
     8.1 Binary file document/timer.pdf has changed
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/drivers/device/MicoTimer.c	Fri Aug 13 10:49:23 2010 +0100
     9.3 @@ -0,0 +1,231 @@
     9.4 +/****************************************************************************
     9.5 +**
     9.6 +**  Name: MicoTimer.c
     9.7 +**
     9.8 +**  Description:
     9.9 +**        Implements functions for manipulating LatticeMico32 Timer
    9.10 +**
    9.11 +**  $Revision: $
    9.12 +**
    9.13 +** Disclaimer:
    9.14 +**
    9.15 +**   This source code is intended as a design reference which
    9.16 +**   illustrates how these types of functions can be implemented.  It
    9.17 +**   is the user's responsibility to verify their design for
    9.18 +**   consistency and functionality through the use of formal
    9.19 +**   verification methods.  Lattice Semiconductor provides no warranty
    9.20 +**   regarding the use or functionality of this code.
    9.21 +**
    9.22 +** --------------------------------------------------------------------
    9.23 +**
    9.24 +**                     Lattice Semiconductor Corporation
    9.25 +**                     5555 NE Moore Court
    9.26 +**                     Hillsboro, OR 97214
    9.27 +**                     U.S.A
    9.28 +**
    9.29 +**                     TEL: 1-800-Lattice (USA and Canada)
    9.30 +**                          (503)268-8001 (other locations)
    9.31 +**
    9.32 +**                     web:   http://www.latticesemi.com
    9.33 +**                     email: techsupport@latticesemi.com
    9.34 +**
    9.35 +** --------------------------------------------------------------------------
    9.36 +**
    9.37 +**  Change History (Latest changes on top)
    9.38 +**
    9.39 +**  Ver    Date        Description
    9.40 +** --------------------------------------------------------------------------
    9.41 +**
    9.42 +**  3.0   Mar-25-2008  Added Header
    9.43 +**
    9.44 +**---------------------------------------------------------------------------
    9.45 +*****************************************************************************/
    9.46 +
    9.47 +
    9.48 +#include "MicoTimer.h"
    9.49 +#include "MicoTimerService.h"
    9.50 +#include "MicoMacros.h"
    9.51 +#include "MicoInterrupts.h"
    9.52 +
    9.53 +
    9.54 +
    9.55 +/**************************************************************************
    9.56 + * driver-debug functions                                                 *
    9.57 + **************************************************************************/
    9.58 +#if _MICO_TIMER_DRIVER_DEBUG_ENABLED_
    9.59 +static void MicoTimerDumpCtx(MicoTimerCtx_t *pCtx)
    9.60 +{
    9.61 +    printf("\n Base     : 0x%x", pCtx->base);
    9.62 +    printf("\n IntrLevel: 0x%x", pCtx->intrLevel);
    9.63 +    printf("\n Context  : 0x%x", pCtx->userCtx);
    9.64 +    printf("\n Callback : 0x%x", pCtx->callback);
    9.65 +    return;
    9.66 +}
    9.67 +
    9.68 +
    9.69 +void MicoTimerDumpRegs(MicoTimerCtx_t *pCtx)
    9.70 +{
    9.71 +    MicoTimer_t *pTimer = (MicoTimer_t *)pCtx->base;
    9.72 +    printf("\n isr-status  : 0x%x",     pTimer->Status);
    9.73 +    printf("\n isr-control : 0x%x",     pTimer->Control);
    9.74 +    printf("\n isr-period  : 0x%x",     pTimer->Period);
    9.75 +    printf("\n isr-snapshot: 0x%x\n",   pTimer->Snapshot);
    9.76 +}
    9.77 +#endif
    9.78 +
    9.79 +
    9.80 +/******************************************************************************
    9.81 + * Timer interrupt-handler                                                    *
    9.82 + ******************************************************************************/
    9.83 +static void MicoTimerISR(unsigned int intrLevel, void *pContext)
    9.84 +{
    9.85 +    /*
    9.86 +     * flow:
    9.87 +     * - clear the timeout-bit
    9.88 +     * - invoke user-registered callback
    9.89 +     */
    9.90 +    MicoTimerCtx_t *ctx = (MicoTimerCtx_t *)pContext;
    9.91 +    volatile MicoTimer_t *pTimer = (MicoTimer_t *)ctx->base;
    9.92 +
    9.93 +    /* acknowledge the interrupt */
    9.94 +    pTimer->Status = 0;
    9.95 +
    9.96 +    /* call the isr */
    9.97 +    if(ctx->callback != 0)
    9.98 +        ((TimerCallback_t)ctx->callback)(ctx->userCtx);
    9.99 +
   9.100 +    return;
   9.101 +}
   9.102 +
   9.103 +
   9.104 +/******************************************************************************
   9.105 + * Initializes a timer                                                        *
   9.106 + *----------------------------------------------------------------------------*
   9.107 + * Inputs:                                                                    *
   9.108 + *     unsigned int IntNum: Interrupt-level                                   *
   9.109 + * Outputs:                                                                   *
   9.110 + * Return values:                                                             *
   9.111 + *            MICO_STATUS_E_INVALID_PARAM                                     *
   9.112 + *            MICO_STATUS_OK                                                  *
   9.113 + ******************************************************************************/
   9.114 +void MicoTimerInit( MicoTimerCtx_t *ctx )
   9.115 +{
   9.116 +    /* stop the timer (if it was running) */
   9.117 +    MicoTimerStop(ctx);
   9.118 +
   9.119 +    /* 
   9.120 +     * Enable interrupts without registering an isr:
   9.121 +     * this way, any spurious timer interrupt that might have
   9.122 +     * existed prior to this init being called, will cause the
   9.123 +     * Mico Interrupt-framework to acknowlede the CPU's interrupt-pending.
   9.124 +     */
   9.125 +    MicoEnableInterrupt(ctx->intrLevel);
   9.126 +
   9.127 +    /* register this timer for lookup service */
   9.128 +    ctx->lookupReg.name = ctx->name;
   9.129 +    ctx->lookupReg.deviceType = "TimerDevice";
   9.130 +    ctx->lookupReg.priv = ctx;
   9.131 +    MicoRegisterDevice( &(ctx->lookupReg) );
   9.132 +
   9.133 +    /* all done */
   9.134 +    return;
   9.135 +}
   9.136 +
   9.137 +
   9.138 +/******************************************************************************
   9.139 + * Starts a Mico32 timer                                                      *
   9.140 + *----------------------------------------------------------------------------*
   9.141 + * Inputs:                                                                    *
   9.142 + *     MicoTimerCtx_t *ctx: pointer to valid ctx                              *
   9.143 + *                                                                            *
   9.144 + *     TimerCallback_t callback: User-provided callback function, called      *
   9.145 + *             in interrupt-context.                                          *
   9.146 + *                                                                            *
   9.147 + *     void *priv: user-provided data that will be called in the callback     *
   9.148 + *                                                                            *
   9.149 + *     unsigned int timercount: ticks to load counter with                    *
   9.150 + *                                                                            *
   9.151 + *     int periodic: if 1, the timer is programmed to auto-load, else         *
   9.152 + *           timer is programmed not to reload on reaching terminal value     *
   9.153 + *                                                                            *
   9.154 + * Note: user MUST supply a valid ctx.                                        *
   9.155 + *       user MUST make sure timerCount is non-zero                           *
   9.156 + ******************************************************************************/
   9.157 +mico_status
   9.158 +MicoTimerStart( MicoTimerCtx_t *ctx, TimerCallback_t callback, void *priv, unsigned int timerCount, int periodic )
   9.159 +{
   9.160 +    volatile MicoTimer_t *pTimer;
   9.161 +    unsigned int regValue;
   9.162 +
   9.163 +    if( (ctx == 0) || (timerCount == 0) )
   9.164 +        return(MICO_STATUS_E_INVALID_PARAM);
   9.165 +
   9.166 +    /* flow:
   9.167 +     * - stop the timer,
   9.168 +     * - load new timerCount,
   9.169 +     * - configure the timer, taking into account the periodicity
   9.170 +     * - register the isr (user MUST provide an isr)
   9.171 +     * - start the timer.
   9.172 +     */
   9.173 +    pTimer          = (MicoTimer_t *)(ctx->base);
   9.174 +    regValue        = (MICO32_TIMER_CONTROL_START_BIT_MASK|MICO32_TIMER_CONTROL_INT_BIT_MASK);
   9.175 +    ctx->callback   = (void *)callback;
   9.176 +    ctx->userCtx    = priv;
   9.177 +
   9.178 +    MicoRegisterISR(ctx->intrLevel, ctx, MicoTimerISR);
   9.179 +
   9.180 +    if(periodic != 0)
   9.181 +        regValue |= MICO32_TIMER_CONTROL_CONT_BIT_MASK;
   9.182 +
   9.183 +
   9.184 +    pTimer->Control = MICO32_TIMER_CONTROL_STOP_BIT_MASK;
   9.185 +    pTimer->Period  = timerCount;
   9.186 +    pTimer->Control = regValue;
   9.187 +
   9.188 +
   9.189 +    return(MICO_STATUS_OK);
   9.190 +}
   9.191 +
   9.192 +
   9.193 +/******************************************************************************
   9.194 + *                                                                            *
   9.195 + * Stops a Mico32 timer                                                       *
   9.196 + *                                                                            *
   9.197 + *----------------------------------------------------------------------------*
   9.198 + *                                                                            *
   9.199 + * Note: user MUST supply a valid ctx.                                        *
   9.200 + *                                                                            *
   9.201 + ******************************************************************************/
   9.202 +mico_status
   9.203 +MicoTimerStop(MicoTimerCtx_t *ctx)
   9.204 +{
   9.205 +    volatile MicoTimer_t *pTimer;
   9.206 +    if(ctx == 0)
   9.207 +        return(MICO_STATUS_E_INVALID_PARAM);
   9.208 +
   9.209 +
   9.210 +    /* stop the timer first and ack any pending interrupts */
   9.211 +    pTimer = (MicoTimer_t *)(ctx->base);
   9.212 +    pTimer->Control = MICO32_TIMER_CONTROL_STOP_BIT_MASK;
   9.213 +    pTimer->Status = 0;
   9.214 +
   9.215 +    /* all done */
   9.216 +    return(MICO_STATUS_OK);
   9.217 +}
   9.218 +
   9.219 +
   9.220 +/******************************************************************************
   9.221 + * reads timer-snapshot                                                       *
   9.222 + *----------------------------------------------------------------------------*
   9.223 + * Note: user MUST supply a valid ctx.                                        *
   9.224 + ******************************************************************************/
   9.225 +unsigned int MicoTimerSnapshot( MicoTimerCtx_t *ctx)
   9.226 +{
   9.227 +    volatile MicoTimer_t *pTimer;
   9.228 +    if(ctx == 0){
   9.229 +        return(0);
   9.230 +    }
   9.231 +    pTimer = (MicoTimer_t *)(ctx->base);
   9.232 +    return(pTimer->Snapshot);
   9.233 +}
   9.234 +
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/drivers/device/MicoTimer.h	Fri Aug 13 10:49:23 2010 +0100
    10.3 @@ -0,0 +1,153 @@
    10.4 +/****************************************************************************
    10.5 +**
    10.6 +**  Name: MicoTimer.h
    10.7 +**
    10.8 +**  Description:
    10.9 +**        Implements functions for manipulating LatticeMico32 Timer and
   10.10 +**        defines timer register map
   10.11 +**
   10.12 +**  $Revision: $
   10.13 +**
   10.14 +** Disclaimer:
   10.15 +**
   10.16 +**   This source code is intended as a design reference which
   10.17 +**   illustrates how these types of functions can be implemented.  It
   10.18 +**   is the user's responsibility to verify their design for
   10.19 +**   consistency and functionality through the use of formal
   10.20 +**   verification methods.  Lattice Semiconductor provides no warranty
   10.21 +**   regarding the use or functionality of this code.
   10.22 +**
   10.23 +** --------------------------------------------------------------------
   10.24 +**
   10.25 +**                     Lattice Semiconductor Corporation
   10.26 +**                     5555 NE Moore Court
   10.27 +**                     Hillsboro, OR 97214
   10.28 +**                     U.S.A
   10.29 +**
   10.30 +**                     TEL: 1-800-Lattice (USA and Canada)
   10.31 +**                          (503)268-8001 (other locations)
   10.32 +**
   10.33 +**                     web:   http://www.latticesemi.com
   10.34 +**                     email: techsupport@latticesemi.com
   10.35 +**
   10.36 +** --------------------------------------------------------------------------
   10.37 +**
   10.38 +**  Change History (Latest changes on top)
   10.39 +**
   10.40 +**  Ver    Date        Description
   10.41 +** --------------------------------------------------------------------------
   10.42 +**
   10.43 +**  3.0   Mar-25-2008  Added Header
   10.44 +**
   10.45 +**---------------------------------------------------------------------------
   10.46 +*****************************************************************************/
   10.47 +
   10.48 +#ifndef MICO32_MICOTIMER_HEADER_FILE
   10.49 +#define MICO32_MICOTIMER_HEADER_FILE
   10.50 +
   10.51 +#include "MicoTypes.h"
   10.52 +#include "DDStructs.h"
   10.53 +
   10.54 +/****************************************************************************
   10.55 + * Mico-timer driver provides the ability to use a Mico-32 timer in either  *
   10.56 + * a single-shot mode or a periodic mode.                                   *
   10.57 + *--------------------------------------------------------------------------*
   10.58 + * Mico Timers must be located in a non-cached region to use this driver    *
   10.59 + ****************************************************************************/
   10.60 +
   10.61 +
   10.62 +#ifdef __cplusplus
   10.63 +extern "C"
   10.64 +{
   10.65 +#endif /* __cplusplus */
   10.66 +
   10.67 +
   10.68 +/******************************************************************************
   10.69 + * Data Structures:                                                           *
   10.70 + ******************************************************************************/
   10.71 +    /* timer callback function type */
   10.72 +    typedef void(*TimerCallback_t)(void *);
   10.73 +
   10.74 +
   10.75 +    /* mico-timer register structure */
   10.76 +    typedef struct st_MicoTimer{
   10.77 +        volatile unsigned int Status;
   10.78 +        volatile unsigned int Control;
   10.79 +        volatile unsigned int Period;
   10.80 +        volatile unsigned int Snapshot;
   10.81 +    }MicoTimer_t;
   10.82 +
   10.83 +
   10.84 +    /**************************************************************************
   10.85 +     * MICO32 TIMER REGISTER DEFINITIONS                                      *
   10.86 +     * (NOTE: OFFSETS REPRESENT BYTES)                                        *
   10.87 +     **************************************************************************/
   10.88 +    #define MICO32_TIMER_STATUS_REG_OFFSET                  (0x00)
   10.89 +    #define MICO32_TIMER_CONTROL_REG_OFFSET                 (0x04)
   10.90 +    #define MICO32_TIMER_PERIOD_REG_OFFSET                  (0x08)
   10.91 +    #define MICO32_TIMER_SNAPSHOT_REG_OFFSET                (0x0c)
   10.92 +
   10.93 +
   10.94 +    /* status-register bits: */
   10.95 +    #define MICO32_TIMER_STATUS_TO_BIT_MASK                 (0x1)
   10.96 +
   10.97 +
   10.98 +    /* control-register bits */
   10.99 +    #define MICO32_TIMER_CONTROL_INT_BIT_MASK               (0x1)
  10.100 +    #define MICO32_TIMER_CONTROL_CONT_BIT_MASK              (0x2)
  10.101 +    #define MICO32_TIMER_CONTROL_START_BIT_MASK             (0x4)
  10.102 +    #define MICO32_TIMER_CONTROL_STOP_BIT_MASK              (0x8)
  10.103 +
  10.104 +
  10.105 +/******************************************************************************
  10.106 + * functions                                                                  *
  10.107 + ******************************************************************************/
  10.108 +
  10.109 +/* initializes Mico32 timer */
  10.110 +void MicoTimerInit( MicoTimerCtx_t *ctx );
  10.111 +
  10.112 +
  10.113 +/*
  10.114 + ******************************************************************************
  10.115 + * Starts a Mico32 timer                                                      *
  10.116 + *----------------------------------------------------------------------------*
  10.117 + * Inputs:                                                                    *
  10.118 + *     MicoTimerCtx_t *ctx: pointer to valid ctx                              *
  10.119 + *                                                                            *
  10.120 + *     TimerCallback_t callback: User-provided callback function, called      *
  10.121 + *             in interrupt-context.                                          *
  10.122 + *             typedef void(*TimerCallback_t)(void *)                         *
  10.123 + *                                                                            *
  10.124 + *     void *priv: user-provided data that will be called in the callback     *
  10.125 + *                                                                            *
  10.126 + *     unsigned int timercount: ticks to load counter with                    *
  10.127 + *                                                                            *
  10.128 + *     int periodic: if 1, the timer is programmed to auto-load, else         *
  10.129 + *           timer is programmed not to reload on reaching terminal value     *
  10.130 + *                                                                            *
  10.131 + * Note: user MUST supply a valid ctx.                                        *
  10.132 + *       user MUST make sure timerCount is non-zero                           *
  10.133 + ******************************************************************************
  10.134 + */
  10.135 +mico_status MicoTimerStart( MicoTimerCtx_t *ctx, TimerCallback_t callback,
  10.136 +            void *priv, unsigned int timerCount, int periodic );
  10.137 +
  10.138 +
  10.139 +/* stops a mico-32 timer */
  10.140 +mico_status MicoTimerStop(MicoTimerCtx_t *ctx);
  10.141 +
  10.142 +
  10.143 +/*
  10.144 + * Reads timer-count snapshot; snapshot value is returned
  10.145 + * as function return value
  10.146 + */
  10.147 +unsigned int MicoTimerSnapshot(MicoTimerCtx_t *ctx);
  10.148 +
  10.149 +
  10.150 +#ifdef __cplusplus
  10.151 +};
  10.152 +#endif /* __cplusplus */
  10.153 +
  10.154 +
  10.155 +#endif /*MICO32_MICOTIMER_HEADER_FILE */
  10.156 +
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/drivers/peripheral.mk	Fri Aug 13 10:49:23 2010 +0100
    11.3 @@ -0,0 +1,9 @@
    11.4 +#---------------------------------------------------------
    11.5 +# Identify source-paths for this device's driver-sources,
    11.6 +# compiled when building the library
    11.7 +#---------------------------------------------------------
    11.8 +LIBRARY_C_SRCS	+= MicoTimer.c	\
    11.9 +		MicoTimerService.c
   11.10 +
   11.11 +LIBRARY_ASM_SRCS += 
   11.12 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/drivers/service/MicoTimerService.c	Fri Aug 13 10:49:23 2010 +0100
    12.3 @@ -0,0 +1,248 @@
    12.4 +/****************************************************************************
    12.5 +**
    12.6 +**  Name: MicoTimerService.c
    12.7 +**
    12.8 +**  Description:
    12.9 +**        Implements timer service functionality:
   12.10 +**               -- registering a timer as a system timer (64-bit)
   12.11 +**                  and retrieving the system tick
   12.12 +**
   12.13 +**               -- registering a timer as a "lookup-able" device
   12.14 +**                  (user does not have to work with these functions)                  
   12.15 +**
   12.16 +**  $Revision: $
   12.17 +**
   12.18 +** Disclaimer:
   12.19 +**
   12.20 +**   This source code is intended as a design reference which
   12.21 +**   illustrates how these types of functions can be implemented.  It
   12.22 +**   is the user's responsibility to verify their design for
   12.23 +**   consistency and functionality through the use of formal
   12.24 +**   verification methods.  Lattice Semiconductor provides no warranty
   12.25 +**   regarding the use or functionality of this code.
   12.26 +**
   12.27 +** --------------------------------------------------------------------
   12.28 +**
   12.29 +**                     Lattice Semiconductor Corporation
   12.30 +**                     5555 NE Moore Court
   12.31 +**                     Hillsboro, OR 97214
   12.32 +**                     U.S.A
   12.33 +**
   12.34 +**                     TEL: 1-800-Lattice (USA and Canada)
   12.35 +**                          (503)268-8001 (other locations)
   12.36 +**
   12.37 +**                     web:   http://www.latticesemi.com
   12.38 +**                     email: techsupport@latticesemi.com
   12.39 +**
   12.40 +** --------------------------------------------------------------------------
   12.41 +**
   12.42 +**  Change History (Latest changes on top)
   12.43 +**
   12.44 +**  Ver    Date        Description
   12.45 +** --------------------------------------------------------------------------
   12.46 +**
   12.47 +**  3.0   Mar-25-2008  Added Header
   12.48 +**
   12.49 +**---------------------------------------------------------------------------
   12.50 +*****************************************************************************/
   12.51 +
   12.52 +#include "MicoTimerService.h"
   12.53 +#include "MicoUtils.h"
   12.54 +#include "MicoMacros.h"
   12.55 +#include "MicoInterrupts.h"
   12.56 +#include "LookupServices.h"
   12.57 +
   12.58 +
   12.59 +#ifdef __cplusplus
   12.60 +extern "C"
   12.61 +{
   12.62 +#endif /* __cplusplus */
   12.63 +
   12.64 +
   12.65 +/******************************************************************************
   12.66 + * Type-definitions and manifest constants and structures                     *
   12.67 + ******************************************************************************/
   12.68 +typedef struct st_ActivityListEntry{
   12.69 +    void                    *ctx;
   12.70 +    MicoSysTimerActivity_t  activity;
   12.71 +}ActivityListEntry_t;
   12.72 +
   12.73 +
   12.74 +/******************************************************************************
   12.75 + * data memebers                                                              *
   12.76 + ******************************************************************************/
   12.77 +static ActivityListEntry_t      s_SysTimerActivity   = {0,0};
   12.78 +static MicoTimerCtx_t           *s_MicoSystemTimer   = 0;
   12.79 +static unsigned long long int   s_MicoCPUTicks;
   12.80 +static unsigned int             s_MicoSysTicks;
   12.81 +
   12.82 +#ifdef __cplusplus
   12.83 +}
   12.84 +#endif /* __cplusplus */
   12.85 +
   12.86 +/******************************************************************************
   12.87 + * debug routines                                                             *
   12.88 + ******************************************************************************/
   12.89 +#ifdef _MICO_TIMER_SERVICES_DEBUG_ENABLED_
   12.90 +
   12.91 +void DumpMicoTimerServicesActivityList()
   12.92 +{
   12.93 +    /* ToDo */
   12.94 +}
   12.95 +
   12.96 +
   12.97 +void DumpMicoTimerServicesRegisteredTimers()
   12.98 +{
   12.99 +    /* ToDo */
  12.100 +}
  12.101 +
  12.102 +#endif
  12.103 +
  12.104 +
  12.105 +/******************************************************************************
  12.106 + * system-timer ISR                                                           *
  12.107 + ******************************************************************************/
  12.108 +static void MicoTimerServicesSysTimerISR(void *pContext)
  12.109 +{
  12.110 +    MicoSysTimerActivity_t activity;
  12.111 +
  12.112 +    /* increment CPU ticks */
  12.113 +    s_MicoCPUTicks += s_MicoSysTicks;
  12.114 +
  12.115 +    /* if there's an activity registered for system-tick, invoke it */
  12.116 +    if(s_SysTimerActivity.activity != 0){
  12.117 +        activity = s_SysTimerActivity.activity;
  12.118 +        activity(s_SysTimerActivity.ctx);
  12.119 +    };
  12.120 +
  12.121 +    return;
  12.122 +}
  12.123 +
  12.124 +
  12.125 +
  12.126 +/******************************************************************************
  12.127 + * Initializes TimerServices                                                  *
  12.128 + ******************************************************************************/
  12.129 +static void MicoTimerServicesInit()
  12.130 +{
  12.131 +    static int s_Initialized = 0;
  12.132 +    if(s_Initialized == 0) {
  12.133 +        s_Initialized = 1;
  12.134 +        s_SysTimerActivity.activity = 0;
  12.135 +        s_MicoSystemTimer           = 0;
  12.136 +        s_MicoCPUTicks              = 0;
  12.137 +    }
  12.138 +}
  12.139 +
  12.140 +
  12.141 +/******************************************************************************
  12.142 + * registers a system-timer if one isn't already registered..                 *
  12.143 + ******************************************************************************/
  12.144 +MicoTimerCtx_t* RegisterSystemTimer(MicoTimerCtx_t *pTimer, unsigned int TicksInMS)
  12.145 +{
  12.146 +	MicoTimerServicesInit();
  12.147 +
  12.148 +    /* 
  12.149 +     * If there's a system-timer registered, don't modify it but simply
  12.150 +     * return its context information
  12.151 +     */
  12.152 +    if(s_MicoSystemTimer != 0)
  12.153 +        return(s_MicoSystemTimer);
  12.154 +
  12.155 +    /*
  12.156 +     * there's none, so register this one as the system-timer
  12.157 +     */
  12.158 +    if(pTimer != 0){
  12.159 +        s_MicoSystemTimer = pTimer;
  12.160 +        if(TicksInMS == 0)
  12.161 +            TicksInMS = 1;
  12.162 +        s_MicoSysTicks = (TicksInMS * (MICO32_CPU_CLOCK_MHZ/1000));
  12.163 +        MicoTimerStart( s_MicoSystemTimer,
  12.164 +                        MicoTimerServicesSysTimerISR,
  12.165 +                        0,
  12.166 +                        s_MicoSysTicks-1,
  12.167 +                        1);
  12.168 +    }
  12.169 +
  12.170 +    return(s_MicoSystemTimer);
  12.171 +}
  12.172 +
  12.173 +
  12.174 +
  12.175 +/******************************************************************************
  12.176 + * get cpu-ticks                                                              *
  12.177 + ******************************************************************************/
  12.178 +void MicoGetCPUTicks(unsigned long long int *ticks)
  12.179 +{
  12.180 +    /* 
  12.181 +     * We need to get a finer resolution than the system-tick and also
  12.182 +     * account for a possible roll-over just after we read the snaphot.
  12.183 +     * We're definitely not going to be exact on the dot but we'll be
  12.184 +     * pretty darn close; higher the clock-speed, less the error (in
  12.185 +     * seconds).
  12.186 +     */
  12.187 +    unsigned long long int cpuTicks = 0;
  12.188 +    unsigned int intrMask;
  12.189 +    unsigned int snapshot;
  12.190 +
  12.191 +    if(s_MicoSystemTimer != 0) {
  12.192 +
  12.193 +        /* disable interrupts and read the gross resolution tick-count */
  12.194 +        intrMask = MicoDisableInterrupts();
  12.195 +        cpuTicks = s_MicoCPUTicks;
  12.196 +
  12.197 +
  12.198 +        /* read the snapshot to get a finer tuning */
  12.199 +        snapshot = MicoTimerSnapshot(s_MicoSystemTimer);
  12.200 +
  12.201 +
  12.202 +        /* 
  12.203 +         * Since the timer is an external peripheral over a bus, there may be
  12.204 +         * contention and we may not get the right reading.  So allow another
  12.205 +         * interrupt if it happened, to make our tick-reading as accurate
  12.206 +         * as possible.
  12.207 +         */
  12.208 +        MicoEnableInterrupt(s_MicoSystemTimer->intrLevel);
  12.209 +
  12.210 +
  12.211 +        /* we're done; decide what our reading should be */
  12.212 +        MicoDisableInterrupts();
  12.213 +        if(cpuTicks == s_MicoCPUTicks)
  12.214 +            cpuTicks += (s_MicoSysTicks - snapshot -1);
  12.215 +        else
  12.216 +            cpuTicks = s_MicoCPUTicks;
  12.217 +
  12.218 +
  12.219 +        /* restore interrupts */
  12.220 +        MicoEnableInterrupts(intrMask);
  12.221 +    }
  12.222 +
  12.223 +    if(ticks != 0)
  12.224 +        *ticks = cpuTicks;
  12.225 +
  12.226 +    return;
  12.227 +}
  12.228 +
  12.229 +
  12.230 +/******************************************************************************
  12.231 + * Registers a periodic-activity (system-timer ticks)                         *
  12.232 + *----------------------------------------------------------------------------*
  12.233 + * System-timer must exist for this to function correctly.                    *
  12.234 + ******************************************************************************/
  12.235 +void MicoRegisterActivity(MicoSysTimerActivity_t activity, void *ctx)
  12.236 +{
  12.237 +	MicoTimerServicesInit();
  12.238 +
  12.239 +    if(s_MicoSystemTimer == 0)
  12.240 +        return;
  12.241 +
  12.242 +    MicoDisableInterrupt(s_MicoSystemTimer->intrLevel);
  12.243 +
  12.244 +    s_SysTimerActivity.ctx      = ctx;
  12.245 +    s_SysTimerActivity.activity = activity;
  12.246 +
  12.247 +    MicoEnableInterrupt(s_MicoSystemTimer->intrLevel);
  12.248 +
  12.249 +    return;
  12.250 +}
  12.251 +
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/drivers/service/MicoTimerService.h	Fri Aug 13 10:49:23 2010 +0100
    13.3 @@ -0,0 +1,116 @@
    13.4 +/****************************************************************************
    13.5 +**
    13.6 +**  Name: MicoTimerService.h
    13.7 +**
    13.8 +**  Description:
    13.9 +**        Implements timer service functionality:
   13.10 +**               -- registering a timer as a system timer (64-bit)
   13.11 +**                  and retrieving the system tick
   13.12 +**
   13.13 +**               -- registering a timer as a "lookup-able" device
   13.14 +**                  (user does not have to work with these functions)                  
   13.15 +**
   13.16 +**  $Revision: $
   13.17 +**
   13.18 +** Disclaimer:
   13.19 +**
   13.20 +**   This source code is intended as a design reference which
   13.21 +**   illustrates how these types of functions can be implemented.  It
   13.22 +**   is the user's responsibility to verify their design for
   13.23 +**   consistency and functionality through the use of formal
   13.24 +**   verification methods.  Lattice Semiconductor provides no warranty
   13.25 +**   regarding the use or functionality of this code.
   13.26 +**
   13.27 +** --------------------------------------------------------------------
   13.28 +**
   13.29 +**                     Lattice Semiconductor Corporation
   13.30 +**                     5555 NE Moore Court
   13.31 +**                     Hillsboro, OR 97214
   13.32 +**                     U.S.A
   13.33 +**
   13.34 +**                     TEL: 1-800-Lattice (USA and Canada)
   13.35 +**                          (503)268-8001 (other locations)
   13.36 +**
   13.37 +**                     web:   http://www.latticesemi.com
   13.38 +**                     email: techsupport@latticesemi.com
   13.39 +**
   13.40 +** --------------------------------------------------------------------------
   13.41 +**
   13.42 +**  Change History (Latest changes on top)
   13.43 +**
   13.44 +**  Ver    Date        Description
   13.45 +** --------------------------------------------------------------------------
   13.46 +**
   13.47 +**  3.0   Mar-25-2008  Added Header
   13.48 +**
   13.49 +**---------------------------------------------------------------------------
   13.50 +*****************************************************************************/
   13.51 +
   13.52 +
   13.53 +#ifndef MICO32_TIMERSERVICE_HEADER_FILE
   13.54 +#define MICO32_TIMERSERVICE_HEADER_FILE
   13.55 +
   13.56 +#include "MicoTypes.h"
   13.57 +#include "MicoTimer.h"
   13.58 +
   13.59 +
   13.60 +#ifdef __cplusplus
   13.61 +extern "C"
   13.62 +{
   13.63 +#endif /* __cplusplus */
   13.64 +
   13.65 +
   13.66 +/******************************************************************************
   13.67 + * Data Structures/types                                                      *
   13.68 + ******************************************************************************/
   13.69 +typedef void (* MicoSysTimerActivity_t) ( void *);
   13.70 +
   13.71 +
   13.72 +
   13.73 +/******************************************************************************
   13.74 + * functions                                                                  *
   13.75 + ******************************************************************************/
   13.76 +
   13.77 +/* 
   13.78 + * Registers system-tick periodic activity
   13.79 + *  Arguments;
   13.80 + *      MicoSysTimerActivity_t: activity function pointer as described
   13.81 + *      by the prototype.
   13.82 + *      void *ctx: pointer to user-data that will be passed back on
   13.83 + *      system-tick.
   13.84 + */
   13.85 +void MicoRegisterActivity(MicoSysTimerActivity_t activity, void *ctx);
   13.86 +
   13.87 +
   13.88 +/* 
   13.89 + * Retrieves 64-bit tick count, if a system-timer is registered.
   13.90 + * Else, it returns 0.
   13.91 + */
   13.92 +void MicoGetCPUTicks(unsigned long long int *ticks);
   13.93 +
   13.94 +
   13.95 +/* 
   13.96 + * Registers system-timer if one isn't already registered.  Once registered,
   13.97 + * you cannot register some other timer as a the system timer.  You can
   13.98 + * always stop the timer using LatticeMico32 device-driver routine
   13.99 + * and bring the system-timer to a halt.
  13.100 + *  Arguments:
  13.101 + *      MicoTimerCtx_t *ctx: LatticeMico32 Timer instance information
  13.102 + *      structure (context) that should be used as the system timer.
  13.103 + *      unsigned int TickInMS: system-tick value in milli-seconds.
  13.104 + *  Return Value:
  13.105 + *      MicoTimerCtx_t *: LatticeMico32 timer instance information structure
  13.106 + *      of the timer being used as the system-timer.  If there is no system
  13.107 + *      timer, it returns 0.
  13.108 + */
  13.109 +MicoTimerCtx_t* RegisterSystemTimer(MicoTimerCtx_t *ctx, unsigned int TickInMS);
  13.110 +
  13.111 +
  13.112 +
  13.113 +#ifdef __cplusplus
  13.114 +};
  13.115 +#endif /* __cplusplus */
  13.116 +
  13.117 +
  13.118 +#endif
  13.119 +
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/rtl/verilog/timer.v	Fri Aug 13 10:49:23 2010 +0100
    14.3 @@ -0,0 +1,351 @@
    14.4 +// =============================================================================
    14.5 +//                           COPYRIGHT NOTICE
    14.6 +// Copyright 2006 (c) Lattice Semiconductor Corporation
    14.7 +// ALL RIGHTS RESERVED
    14.8 +// This confidential and proprietary software may be used only as authorised by
    14.9 +// a licensing agreement from Lattice Semiconductor Corporation.
   14.10 +// The entire notice above must be reproduced on all authorized copies and
   14.11 +// copies may only be made to the extent permitted by a licensing agreement from
   14.12 +// Lattice Semiconductor Corporation.
   14.13 +//
   14.14 +// Lattice Semiconductor Corporation        TEL : 1-800-Lattice (USA and Canada)
   14.15 +// 5555 NE Moore Court                            408-826-6000 (other locations)
   14.16 +// Hillsboro, OR 97124                     web  : http://www.latticesemi.com/
   14.17 +// U.S.A                                   email: techsupport@latticesemi.com
   14.18 +// =============================================================================/
   14.19 +//                         FILE DETAILS
   14.20 +// Project          : LM32 Timer
   14.21 +// File             : timer.v
   14.22 +// Title            : Timer component core file
   14.23 +// Dependencies     : None
   14.24 +// Version          : 7.0
   14.25 +//                  : Initial Release
   14.26 +// Version          : 7.0SP2, 3.0
   14.27 +//                  : No Change
   14.28 +// =============================================================================
   14.29 +`ifndef TIMER_FILE
   14.30 +`define TIMER_FILE
   14.31 +module timer #(
   14.32 +   parameter PERIOD_NUM   = 20,//decimal
   14.33 +   parameter PERIOD_WIDTH = 16,//decimal
   14.34 +   parameter WRITEABLE_PERIOD  = 1,
   14.35 +   parameter READABLE_SNAPSHOT = 1,
   14.36 +   parameter START_STOP_CONTROL = 1,
   14.37 +   parameter TIMEOUT_PULSE = 1,
   14.38 +   parameter WATCHDOG = 0)
   14.39 +             (
   14.40 +             //slave port
   14.41 +             S_ADR_I,    //32bits
   14.42 +             S_DAT_I,    //32bits
   14.43 +             S_WE_I,
   14.44 +             S_STB_I,
   14.45 +             S_CYC_I,
   14.46 +             S_CTI_I,
   14.47 +             S_BTE_I,
   14.48 +             S_LOCK_I,
   14.49 +             S_SEL_I,
   14.50 +             S_DAT_O,    //32bits
   14.51 +             S_ACK_O,
   14.52 +             S_RTY_O,
   14.53 +             S_ERR_O,
   14.54 +             S_INT_O,
   14.55 +             RSTREQ_O,   //resetrequest, only used when WatchDog enabled
   14.56 +             TOPULSE_O,  //timeoutpulse, only used when TimeOutPulse enabled
   14.57 +             //system clock and reset
   14.58 +             CLK_I,
   14.59 +             RST_I
   14.60 +             );
   14.61 +
   14.62 +   input  [31:0]  S_ADR_I;
   14.63 +   input  [31:0]  S_DAT_I;
   14.64 +   input          S_WE_I;
   14.65 +   input          S_STB_I;
   14.66 +   input          S_CYC_I;
   14.67 +   input  [2:0]   S_CTI_I;
   14.68 +   input          S_LOCK_I;
   14.69 +   input  [3:0]   S_SEL_I;
   14.70 +   input  [1:0]   S_BTE_I;
   14.71 +   output [31:0]  S_DAT_O;
   14.72 +   output         S_ACK_O;
   14.73 +   output         S_INT_O;
   14.74 +   output         S_RTY_O;
   14.75 +   output         S_ERR_O;
   14.76 +   output         RSTREQ_O;
   14.77 +   output         TOPULSE_O;
   14.78 +
   14.79 +   input          CLK_I;
   14.80 +   input          RST_I;
   14.81 +
   14.82 +   parameter  UDLY     = 1;
   14.83 +   parameter  ST_IDLE  = 2'b00;
   14.84 +   parameter  ST_CNT   = 2'b01;
   14.85 +   parameter  ST_STOP  = 2'b10;
   14.86 +
   14.87 +   reg  dw00_cs;
   14.88 +   reg  dw04_cs;
   14.89 +   reg  dw08_cs;
   14.90 +   reg  dw0c_cs;
   14.91 +   reg  reg_wr;
   14.92 +   reg  reg_rd;
   14.93 +   reg  [31:0] latch_s_data;
   14.94 +   reg  [1:0]  reg_04_data;
   14.95 +   reg         reg_run;
   14.96 +   reg         reg_stop;
   14.97 +   reg         reg_start;
   14.98 +   reg [1:0]   status;
   14.99 +   reg  [PERIOD_WIDTH-1:0] internal_counter;
  14.100 +   reg  [PERIOD_WIDTH-1:0] reg_08_data;
  14.101 +   reg  s_ack_dly;
  14.102 +   reg  s_ack_2dly;
  14.103 +   reg  s_ack_pre;
  14.104 +   reg  RSTREQ_O;
  14.105 +   reg  TOPULSE_O;
  14.106 +   reg  reg_to;
  14.107 +
  14.108 +   wire        reg_cont;
  14.109 +   wire        reg_ito;
  14.110 +   wire [1:0]  read_00_data;
  14.111 +   wire [1:0]  read_04_data;
  14.112 +   wire [PERIOD_WIDTH-1:0] read_08_data;
  14.113 +   wire [PERIOD_WIDTH-1:0] read_0c_data;
  14.114 +   wire [PERIOD_WIDTH-1:0] reg_period;
  14.115 +   wire        S_ACK_O;
  14.116 +   wire [31:0] S_DAT_O;
  14.117 +   wire        S_INT_O;
  14.118 +
  14.119 +   assign     S_RTY_O = 1'b0;
  14.120 +   assign     S_ERR_O = 1'b0;
  14.121 +
  14.122 +   always @(posedge CLK_I or posedge RST_I)
  14.123 +     if(RST_I)
  14.124 +       latch_s_data     <= #UDLY 32'h0;
  14.125 +     else
  14.126 +       latch_s_data     <= #UDLY S_DAT_I;
  14.127 +
  14.128 +   always @(posedge CLK_I or posedge RST_I)
  14.129 +     if(RST_I)
  14.130 +       begin
  14.131 +          dw00_cs   <= #UDLY 1'b0;
  14.132 +          dw04_cs   <= #UDLY 1'b0;
  14.133 +          dw08_cs   <= #UDLY 1'b0;
  14.134 +          dw0c_cs   <= #UDLY 1'b0;
  14.135 +       end
  14.136 +     else
  14.137 +       begin
  14.138 +          dw00_cs   <= #UDLY (!(|S_ADR_I[5:2]));
  14.139 +          dw04_cs   <= #UDLY (S_ADR_I[5:2] == 4'h1);
  14.140 +          dw08_cs   <= #UDLY (S_ADR_I[5:2] == 4'h2);
  14.141 +          dw0c_cs   <= #UDLY (S_ADR_I[5:2] == 4'h3);
  14.142 +       end
  14.143 +
  14.144 +   always @(posedge CLK_I or posedge RST_I)
  14.145 +     if(RST_I)
  14.146 +       begin
  14.147 +          reg_wr    <= #UDLY 1'b0;
  14.148 +          reg_rd    <= #UDLY 1'b0;
  14.149 +       end
  14.150 +     else
  14.151 +       begin
  14.152 +          reg_wr    <= #UDLY S_WE_I && S_STB_I && S_CYC_I;
  14.153 +          reg_rd    <= #UDLY !S_WE_I && S_STB_I && S_CYC_I;
  14.154 +       end
  14.155 +
  14.156 +   generate
  14.157 +   if (START_STOP_CONTROL == 1)
  14.158 +
  14.159 +   always @(posedge CLK_I or posedge RST_I)
  14.160 +     if(RST_I)
  14.161 +       begin
  14.162 +          status                   <= #UDLY ST_IDLE;
  14.163 +          internal_counter         <= #UDLY 'h0;
  14.164 +       end
  14.165 +     else
  14.166 +       case(status)
  14.167 +         ST_IDLE:
  14.168 +           begin
  14.169 +             if(reg_wr && dw08_cs)
  14.170 +               begin
  14.171 +               internal_counter <= #UDLY (WRITEABLE_PERIOD == 1) ? latch_s_data : reg_period;
  14.172 +               end
  14.173 +             else if(reg_start && !reg_stop)
  14.174 +               begin
  14.175 +               status           <= #UDLY ST_CNT;
  14.176 +               if(|reg_period)
  14.177 +                 internal_counter <= #UDLY reg_period - 1;
  14.178 +               end
  14.179 +           end
  14.180 +         ST_CNT:
  14.181 +           begin
  14.182 +              if(reg_stop && (|internal_counter))
  14.183 +                status           <= #UDLY ST_STOP;
  14.184 +              else if(reg_wr && dw08_cs)
  14.185 +                begin
  14.186 +                internal_counter <= #UDLY (WRITEABLE_PERIOD == 1) ? latch_s_data : reg_period;
  14.187 +                if(!(|internal_counter) && !reg_cont)
  14.188 +                   status        <= #UDLY ST_IDLE;
  14.189 +                end
  14.190 +              else if(!(|internal_counter))
  14.191 +                begin
  14.192 +                if(!reg_cont)
  14.193 +                  begin
  14.194 +                  status         <= #UDLY ST_IDLE;
  14.195 +                  end
  14.196 +                internal_counter <= #UDLY reg_period;
  14.197 +                end
  14.198 +              else
  14.199 +                internal_counter <= #UDLY internal_counter - 1;
  14.200 +           end
  14.201 +         ST_STOP:
  14.202 +           begin
  14.203 +              if(reg_start && !reg_stop)
  14.204 +                status           <= #UDLY ST_CNT;
  14.205 +              else if(reg_wr && dw08_cs)
  14.206 +                begin
  14.207 +                internal_counter <= #UDLY (WRITEABLE_PERIOD == 1) ? latch_s_data : reg_period;
  14.208 +                end
  14.209 +           end
  14.210 +        default:
  14.211 +           begin
  14.212 +              status               <= #UDLY ST_IDLE;
  14.213 +              internal_counter     <= #UDLY 'h0;
  14.214 +           end
  14.215 +       endcase
  14.216 +   endgenerate
  14.217 +
  14.218 +
  14.219 +   generate
  14.220 +   if (START_STOP_CONTROL == 0)
  14.221 +   always @(posedge CLK_I or posedge RST_I)
  14.222 +     if(RST_I)
  14.223 +       internal_counter         <= #UDLY 'h0;
  14.224 +     else if ((reg_wr && dw08_cs) && (WATCHDOG == 1) || !(|internal_counter))
  14.225 +       internal_counter         <= #UDLY reg_period;
  14.226 +     else
  14.227 +       internal_counter         <= #UDLY internal_counter - 1;
  14.228 +   endgenerate
  14.229 +
  14.230 +   always @(posedge CLK_I or posedge RST_I)
  14.231 +     if(RST_I)
  14.232 +       reg_to        <= #UDLY 1'b0;
  14.233 +     else if(reg_wr && dw00_cs && (!latch_s_data[0]))
  14.234 +       reg_to        <= #UDLY 1'b0;
  14.235 +     else if(!(|internal_counter) && reg_ito && ((START_STOP_CONTROL == 0) || reg_run))
  14.236 +       reg_to        <= #UDLY 1'b1;
  14.237 +
  14.238 +   generate
  14.239 +   if (START_STOP_CONTROL == 1)
  14.240 +   always @(posedge CLK_I or posedge RST_I)
  14.241 +     if(RST_I)
  14.242 +       reg_run       <= #UDLY 1'b0;
  14.243 +     else if(reg_stop)
  14.244 +       reg_run       <= #UDLY 1'b0;
  14.245 +     else if(reg_start)
  14.246 +       reg_run       <= #UDLY 1'b1;
  14.247 +     else
  14.248 +       reg_run       <= #UDLY (status !== ST_IDLE);
  14.249 +   endgenerate
  14.250 +
  14.251 +   assign read_00_data   = (START_STOP_CONTROL == 1) ? {reg_run,reg_to} : {1'b1,reg_to};
  14.252 +
  14.253 +   //reg_04:control
  14.254 +   assign      {reg_cont,reg_ito} = reg_04_data;
  14.255 +
  14.256 +   generate
  14.257 +   if (START_STOP_CONTROL == 1)
  14.258 +   always @(posedge CLK_I or posedge RST_I)
  14.259 +     if(RST_I)
  14.260 +       reg_stop      <= #UDLY 1'b0;
  14.261 +     else if(reg_wr && dw04_cs)
  14.262 +       begin
  14.263 +          if(latch_s_data[3] && !latch_s_data[2] && !reg_stop)
  14.264 +            reg_stop  <= #UDLY 1'b1;
  14.265 +          else if(!latch_s_data[3] && latch_s_data[2] && reg_stop)
  14.266 +            reg_stop  <= #UDLY 1'b0;
  14.267 +       end
  14.268 +
  14.269 +   always @(posedge CLK_I or posedge RST_I)
  14.270 +     if(RST_I)
  14.271 +       reg_start     <= #UDLY 1'b0;
  14.272 +     else if(reg_wr && dw04_cs && !reg_run)
  14.273 +       reg_start     <= #UDLY latch_s_data[2];
  14.274 +     else
  14.275 +       reg_start     <= #UDLY 1'b0;
  14.276 +   endgenerate
  14.277 +
  14.278 +   always @(posedge CLK_I or posedge RST_I)
  14.279 +     if(RST_I)
  14.280 +       reg_04_data   <= #UDLY 2'h0;
  14.281 +     else if(reg_wr && dw04_cs)
  14.282 +       reg_04_data   <= #UDLY latch_s_data[1:0];
  14.283 +
  14.284 +   assign  read_04_data   = reg_04_data;
  14.285 +
  14.286 +  generate
  14.287 +  if (WRITEABLE_PERIOD == 1) begin
  14.288 +    assign reg_period     = reg_08_data;
  14.289 +    assign read_08_data   = reg_08_data;
  14.290 +    always @(posedge CLK_I or posedge RST_I) begin
  14.291 +     if (RST_I)
  14.292 +       reg_08_data   <= #UDLY PERIOD_NUM;
  14.293 +     else if ((reg_wr && dw08_cs) && (START_STOP_CONTROL == 1))
  14.294 +       reg_08_data   <= #UDLY latch_s_data;
  14.295 +	 end
  14.296 +   end
  14.297 +  else
  14.298 +     assign reg_period   = PERIOD_NUM;
  14.299 +  endgenerate
  14.300 +
  14.301 +  generate
  14.302 +  if (READABLE_SNAPSHOT == 1)
  14.303 +    assign  read_0c_data   = internal_counter;
  14.304 +  endgenerate
  14.305 +
  14.306 +   always @(posedge CLK_I or posedge RST_I)
  14.307 +     if(RST_I)
  14.308 +       begin
  14.309 +          s_ack_pre     <= #UDLY 1'b0;
  14.310 +          s_ack_dly     <= #UDLY 1'b0;
  14.311 +          s_ack_2dly    <= #UDLY 1'b0;
  14.312 +       end
  14.313 +     else
  14.314 +       begin
  14.315 +          s_ack_pre     <= #UDLY S_STB_I && S_CYC_I;
  14.316 +          s_ack_dly     <= #UDLY s_ack_pre;
  14.317 +          s_ack_2dly    <= #UDLY s_ack_dly;
  14.318 +       end
  14.319 +
  14.320 +   assign S_ACK_O = s_ack_dly & !s_ack_2dly;
  14.321 +   assign S_DAT_O  = (dw00_cs & !S_WE_I & S_STB_I)                     ? read_00_data :
  14.322 +                     (dw04_cs & !S_WE_I & S_STB_I)                     ? read_04_data :
  14.323 +                     (dw08_cs & !S_WE_I & S_STB_I & WRITEABLE_PERIOD)  ? read_08_data :
  14.324 +                     (dw0c_cs & !S_WE_I & S_STB_I & READABLE_SNAPSHOT) ? read_0c_data :
  14.325 +                                                                         32'h0;
  14.326 +   assign S_INT_O  = reg_to;
  14.327 +
  14.328 +  generate
  14.329 +  if (WATCHDOG == 1)
  14.330 +   always @(posedge CLK_I or posedge RST_I) begin
  14.331 +     if(RST_I)
  14.332 +       RSTREQ_O      <= #UDLY 1'b0;
  14.333 +     else if(!(|internal_counter) && !RSTREQ_O && ((START_STOP_CONTROL == 0) || reg_run))
  14.334 +       RSTREQ_O      <= #UDLY 1'b1;
  14.335 +     else
  14.336 +       RSTREQ_O      <= #UDLY 1'b0;
  14.337 +	 end
  14.338 +  endgenerate
  14.339 +
  14.340 +
  14.341 +  generate
  14.342 +  if (TIMEOUT_PULSE == 1)
  14.343 +   //TOPULSE_O
  14.344 +   always @(posedge CLK_I or posedge RST_I)
  14.345 +     if(RST_I)
  14.346 +       TOPULSE_O     <= #UDLY 1'b0;
  14.347 +     else if(!(|internal_counter) && !TOPULSE_O && ((START_STOP_CONTROL == 0) || reg_run))
  14.348 +       TOPULSE_O     <= #UDLY 1'b1;
  14.349 +     else
  14.350 +       TOPULSE_O     <= #UDLY 1'b0;
  14.351 +  endgenerate
  14.352 +
  14.353 +endmodule
  14.354 +`endif
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/timer.xml	Fri Aug 13 10:49:23 2010 +0100
    15.3 @@ -0,0 +1,55 @@
    15.4 +<?xml version="1.0" encoding="UTF-8"?>
    15.5 +<Component Name="timer" Text="Timer" Hide="false" Type="IO" Ver="3.0" Help="timer\document\timer.htm">
    15.6 +	<MasterSlavePorts>
    15.7 +		<SlavePort Prefix="S" Name="S Port" Type="DATA"/>
    15.8 +	</MasterSlavePorts>
    15.9 +        <ClockPort Name="CLK_I " Description="Clock     one"/>
   15.10 +        <ResetPort Name="RST_I " Description="Reset"/>
   15.11 +	<Interrupt Name="S_INT_O" Active="high" IRQ=""/>
   15.12 +	<Defines>
   15.13 +        	<Define Name="TIMER_DEFINED" Value="1" />
   15.14 +                <Define Name="TIMER_BASE_ADDRESS" Type="base_address" Value="0x0000000"/>
   15.15 +        </Defines>
   15.16 +	<DeviceDriver InitRoutine="MicoTimerInit" StructName="MicoTimerCtx_t">
   15.17 +                <DDInclude Include="LookupServices.h"/>
   15.18 +                <DDstruct>
   15.19 +                        <DDSElem MemberName = "name" MemberType = "const char*" Type="Parm" Value="InstanceName" Format = "string"/>
   15.20 +			<DDSElem MemberName = "base" MemberType = "unsigned int" Type="Parm" Value="BASE_ADDRESS" />
   15.21 +                        <DDSElem MemberName = "lookupReg" MemberType = "DeviceReg_t" Type="uninitialized" Value=""/>			
   15.22 +                        <DDSElem MemberName = "intrLevel" MemberType = "unsigned int" Type="Interrupt" Value="IRQ_LEVEL" />
   15.23 +                        <DDSElem MemberName = "userCtx" MemberType = "void *" Type="uninitialized" Value = "" />
   15.24 +                        <DDSElem MemberName = "callback" MemberType = "void *" Type="uninitialized" Value = "" />
   15.25 +                        <DDSElem MemberName = "prev" MemberType = "void *" Type="uninitialized" Value = "" />
   15.26 +                        <DDSElem MemberName = "next" MemberType = "void *" Type="uninitialized"	Value = "" />
   15.27 +		</DDstruct>
   15.28 +		</DeviceDriver>
   15.29 +      <Files>
   15.30 +	    <File Name="../components/timer/rtl/verilog/timer.v" />
   15.31 +      </Files>
   15.32 +	<Parms>
   15.33 +		<Parm Name="InstanceName"    Value="timer"     Type="string" isiname="true" Text="Instance Name"/>
   15.34 +		<Parm Name="BASE_ADDRESS"    Value="0x80000000" Type="Integer" isba="true" Text="Base Address"/>
   15.35 +		<Parm Name="SIZE"            Value="128"         Type="Integer" issize="true" Text="Size" Enable="false"/>
   15.36 +            <Parm Name="ADDRESS_LOCK" Type="Define" Value="undef" Text="Lock Address"/>
   15.37 +		<Parm Name="DISABLE" Type="Define" Value="undef" isuse="true" Text="Disable Component"/>
   15.38 +		<Parm Name="PERIOD_NUM" Type="Integer" Value="20" Text="Default Reload Ticks" isparm="true"/>
   15.39 +		<Parm Name="PERIOD_WIDTH" Type="Integer" Value="32" ValueRange="1-32" Text="Counter Width" isparm="true"/>
   15.40 +		<Parm Name="WRITEABLE_PERIOD" Type="define" Value="def" Text="Writeable Tick Count" isparm="true"/>
   15.41 +		<Parm Name="READABLE_SNAPSHOT" Type="define" Value="def" Text="Readable Tick Count" isparm="true"/>
   15.42 +		<Parm Name="START_STOP_CONTROL" Type="define" Value="def" Text="Start Stop Control" isparm="true"/>
   15.43 +		<Parm Name="WATCHDOG" Type="define" Value="undef" Text="WATCHDOG" Hide="true" isparm="true"/>
   15.44 +	</Parms>
   15.45 +      <GUIS Columns="2" Help="component_help\lm32.htm" Name="timer">
   15.46 +            <GUI Widget="Text" Span="1" Name="InstanceName" Width="40"/>
   15.47 +            <GUI Widget="Text" Span="1" Name="BASE_ADDRESS"/>
   15.48 +
   15.49 +            <GUI Widget="Group" Span="1" Name="OPTIONS" Text="Options" Columns="1"/>
   15.50 +            <GUI Widget="Check" Span="1" Name="WRITEABLE_PERIOD"/>
   15.51 +            <GUI Widget="Check" Span="1" Name="READABLE_SNAPSHOT"/>
   15.52 +            <GUI Widget="Check" Span="1" Name="START_STOP_CONTROL"/>
   15.53 +
   15.54 +            <GUI Widget="Group" Span="1" Name="SETTINGS" Text="Settings" Columns="2"/>
   15.55 +            <GUI Widget="Text" Span="1" Name="PERIOD_NUM"/>
   15.56 +            <GUI Widget="Spinner" Span="1" Name="PERIOD_WIDTH"/>
   15.57 +      </GUIS>
   15.58 +</Component>