ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/cwcbm/common.h
Revision: 1.1
Committed: 2004-01-07T15:37:45Z (20 years, 10 months ago) by cebix
Content type: text/plain
Branch: MAIN
Branch point for: cebix
Log Message:
Initial revision

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * common.h - Common parts of readcbm and writecbm
3     *
4     * Written in 2003 by Christian Bauer <Christian.Bauer@uni-mainz.de>
5     */
6    
7     #ifndef COMMON_H
8     #define COMMON_H
9    
10     /* Number of tracks (tracks are numbered 1..NUM_TRACKS) */
11     #define NUM_TRACKS 35
12    
13     /* Maximum number of sectors per track */
14     #define MAX_SECTORS 21
15    
16     /* Bytes per sector */
17     #define SECTOR_SIZE 256
18    
19     /* 1541 crystal frequency (16 MHz) */
20     #define CRYSTAL_FREQ 16000000
21    
22     /* 1541 RPM */
23     #define NOMINAL_RPM 300
24    
25     /* Catweasel frequency (7 MHz) */
26     #define CW_FREQ 7080500.0
27    
28     /* Bit rate for each speed zone */
29     const int bps[4] = {
30     CRYSTAL_FREQ / 16 / 4, CRYSTAL_FREQ / 15 / 4,
31     CRYSTAL_FREQ / 14 / 4, CRYSTAL_FREQ / 13 / 4
32     };
33    
34     /* Standard speeds for tracks */
35     const int std_speed[NUM_TRACKS + 1] = {
36     0,
37     3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
38     2, 2, 2, 2, 2, 2, 2,
39     1, 1, 1, 1, 1, 1,
40     0, 0, 0, 0, 0
41     };
42    
43     /* Number of sectors per track, for all tracks */
44     const int num_sectors[NUM_TRACKS + 1] = {
45     0,
46     21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
47     19,19,19,19,19,19,19,
48     18,18,18,18,18,18,
49     17,17,17,17,17
50     };
51    
52     /* Actual RPM of the drive, and double step flag */
53     static int drive_rpm = 300;
54     static int double_step = 0;
55    
56     /* Clock table (nominal number of Catweasel clocks per inter-flux-change gap) */
57     static int clock_table[4] = {0, 0, 0, 0};
58    
59     /* Threshold table */
60     static int thresh_table[3] = {0, 0, 0};
61    
62     /* Track buffer */
63     static unsigned char track_buf[MAX_SECTORS * SECTOR_SIZE];
64    
65     /* Catweasel controller struct */
66     catweasel_contr c;
67    
68    
69     /* Delay specified number of milliseconds */
70     static void msdelay(int ms)
71     {
72     usleep(ms * 1000);
73     }
74    
75    
76     /* Set speed zone and tables */
77     static void set_zone(int track)
78     {
79     int zone = std_speed[track];
80     clock_table[0] = 0;
81     clock_table[1] = CW_FREQ * NOMINAL_RPM * 1 / (bps[zone] * drive_rpm);
82     clock_table[2] = CW_FREQ * NOMINAL_RPM * 2 / (bps[zone] * drive_rpm);
83     clock_table[3] = CW_FREQ * NOMINAL_RPM * 3 / (bps[zone] * drive_rpm);
84     thresh_table[0] = (clock_table[0] + clock_table[1]) / 2;
85     thresh_table[1] = (clock_table[1] + clock_table[2]) / 2;
86     thresh_table[2] = (clock_table[2] + clock_table[3]) / 2;
87     }
88    
89     #endif