home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_10_05 / 1005069a < prev    next >
Text File  |  1992-03-05  |  3KB  |  122 lines

  1. /* Listing 7 */
  2.  
  3. /*****************************************************
  4.     LABMASTR.H
  5.  
  6.     Header file containing basic number defs and 
  7.     function prototypes for the Lab the Lab Master AD.
  8.  
  9.     Copyright Don Bradley, 1991.
  10.  
  11.     Permission is granted for used of these routines
  12.     in any manner as long as this copyright notice is
  13.     included.
  14.  
  15.     Tested using Quick C 2.5 and MSC 6.0 on a 
  16.     Toshiba T5200.
  17.  
  18.  *****************************************************/
  19.  
  20. #define TRUE        1
  21. #define FALSE       0
  22.  
  23. #define LM_BASE    0x02c0
  24. #define LM_ID         0x4e69
  25.  
  26. #define DAC0_DATA            (LM_BASE + 0x00)
  27. #define DAC1_DATA            (LM_BASE + 0x02)
  28. #define PRODUCT            (LM_BASE + 0x02)
  29. #define VERSION            (LM_BASE + 0x03)
  30. #define BRD_ENABLE            (LM_BASE + 0x04)
  31. #define IRQ_CONTROL        (LM_BASE + 0x05)
  32. #define IRQ_STATUS            (LM_BASE + 0x05)
  33. #define TIMER_DATA          (LM_BASE + 0x06)
  34. #define TIMER_CONTROL        (LM_BASE + 0x08)
  35. #define ADC_VIRTCHAN        (LM_BASE + 0x09)
  36. #define ADC_CHN_GAIN_ARRAY (LM_BASE + 0x0a)
  37. #define DIG_OUT            (LM_BASE + 0x0b)
  38. #define DIG_IN                (LM_BASE + 0x0b)
  39. #define DIG_EXP            (LM_BASE + 0x0c)
  40. #define ADC_DATA            (LM_BASE + 0x0c)
  41. #define ADC_LASTCHAN        (LM_BASE + 0x0d)
  42. #define ADC_CONTROL        (LM_BASE + 0x0e)
  43. #define ADC_STATUS            (LM_BASE + 0x0e)
  44. #define DAC_CONTROL        (LM_BASE + 0x0f)
  45. #define DAC_STATUS            (LM_BASE + 0x0f)
  46.  
  47. /* MASK defines */
  48.  
  49. /* ADC defines */
  50. #define ADC_FIFO_ENABLE    0x80
  51. #define ADC_FIFO_DISABLE   0x00
  52. #define ADC_SINGLE_ENDED    0x00
  53. #define ADC_DIFFERENTIAL    0x40
  54. #define ADC_GAIN_1            0x00
  55. #define ADC_GAIN_2            0x40
  56. #define ADC_GAIN_4            0x80
  57. #define ADC_GAIN_8            0xc0
  58. #define ADC_GAIN_10        0x40
  59. #define ADC_GAIN_100        0x80
  60. #define ADC_GAIN_1000        0xc0
  61. #define ADC_BANK_0            0x00
  62. #define ADC_BANK_1            0x10
  63. #define ADC_BANK_2            0x20
  64. #define ADC_BANK_3            0x30
  65.  
  66. #define MAX_CHANNELS            16
  67. #define NON_ADC_VALUE             0x8000
  68. #define ADC_DMA_BUFFER_LEN     0x1000
  69. #define ADC_FIFO_SAMPLE_READY    0x40
  70.  
  71. /* TIMER defines */
  72. #define TIMER_DIVISOR   10
  73. // 4MHz
  74. #define TIMER_F1        4000000L
  75. // 250KHz
  76. #define TIMER_F2        (TIMER_F1/TIMER_DIVISOR)
  77. // 15.625KHz
  78. #define TIMER_F3        (TIMER_F2/TIMER_DIVISOR)
  79. // 976.5625Hz
  80. #define TIMER_F4        (TIMER_F3/TIMER_DIVISOR)
  81. // 61.03516Hz
  82. #define TIMER_F5        (TIMER_F4/TIMER_DIVISOR)
  83.  
  84. /* LabMasterAD function prototypes */
  85.  
  86. /* labmastr.c */
  87. int LabMasterAD_Enable(void);
  88. int LabMasterAD_Disable(void);
  89. int LabMasterAD_Product(void);
  90. int LabMasterAD_Version(void);
  91. void timer_reset(void);
  92. void timer0_off(void);
  93. void timer0_on(void);
  94. void timer5_off(void);
  95. void timer5_on(void);
  96. double timer0_setup(double freq);
  97. void dig_out(int chan, int value);
  98. int dig_in(int chan);
  99. void outpwd(unsigned int port, unsigned int value);
  100. int inpwd(unsigned int port);
  101.  
  102. /* timerad.c */
  103. double timerad(double freq);
  104. void step_timerad(void);
  105.  
  106. /* adcdma.c */
  107. int init_adc_dma(unsigned int num_chn, 
  108.     long num_samples, double *freq, int dma_chn, 
  109.     void (*procfunc)(int));
  110. void get_next_adc_values(void);
  111. void terminate_adc_dma(void);
  112. void clr_adc_dma_buffer(void);
  113. int adc_dma_done(void);
  114. long adc_dma_conversion_count(void);
  115.  
  116. /* adc.c */
  117. int get_adc(unsigned int chn);
  118. void disable_adc(void);
  119. void enable_adc(void);
  120. int adc_status(void);
  121.  
  122.