Allow card.resource to be built with the right name again (by using the
[AROS.git] / arch / m68k-amiga / card / cardaccessspeed.c
blob2b5f1299c25df083e5ed666b88c2f1320e1ac862
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: CardAccessSpeed() function.
6 Lang: english
7 */
9 #include "card_intern.h"
11 AROS_LH2(ULONG, CardAccessSpeed,
12 AROS_LHA(struct CardHandle*, handle, A1),
13 AROS_LHA(ULONG, nanoseconds, D0),
14 struct CardResource*, CardResource, 9, Card)
16 AROS_LIBFUNC_INIT
18 volatile struct GayleIO *gio = (struct GayleIO*)GAYLE_BASE;
19 UBYTE v, speed;
21 CARDDEBUG(bug("CardAccessSpeed(%p,%d)\n", handle, nanoseconds));
23 if (!ISMINE)
24 return 0;
26 speed = 0;
28 if (nanoseconds > 720)
29 return 0;
31 if (nanoseconds > 250) {
32 speed = GAYLE_CFG_720NS;
33 nanoseconds = 720;
34 } else if (nanoseconds > 150) {
35 speed = GAYLE_CFG_250NS;
36 nanoseconds = 250;
37 } else if (nanoseconds > 100) {
38 speed = GAYLE_CFG_150NS;
39 nanoseconds = 150;
40 } else {
41 speed = GAYLE_CFG_100NS;
42 nanoseconds = 100;
45 Disable();
46 v = gio->config & ~GAYLE_CFG_SPEED;
47 v |= speed;
48 gio->config = v;
49 Enable();
51 return nanoseconds;
53 AROS_LIBFUNC_EXIT