Main Page Data Structures File List Data Fields Globals Related Pages

# clib/HWAPI.H

Go to the documentation of this file.

    00001 /****************************************************************************
    00002 *
    00003 * (C) 2000 by BECK IPC GmbH
    00004 *
    00005 *  BECK IPC GmbH
    00006 *  Garbenheimerstr. 38
    00007 *  D-35578 Wetzlar
    00008 *
    00009 *  Phone : (49)-6441-905-240
    00010 *  Fax   : (49)-6441-905-245
    00011 *
    00012
    00013 $Header: HWAPI.H, 8, 04.02.2002 16:44:22, Christoph Stoidner$
    00014
    00015 $Log:
    00016  8    IPC@CHIP  1.7         04.02.2002 16:44:22  Christoph Stoidner add DMA
    00017       WordTransfer
    00018  7    IPC@CHIP  1.6         16.01.2002 14:17:45  Christoph Stoidner add
    00019       GetFrequency defines. restructured DmaInfo struct
    00020  6    IPC@CHIP  1.5         16.01.2002 11:45:04  Christoph Stoidner add starteam
    00021       directives
    00022  5    IPC@CHIP  1.4         16.01.2002 11:04:29  Christoph Stoidner add new
    00023       functions and some comments
    00024  4    IPC@CHIP  1.3         31.05.2001 16:18:24  Christoph Stoidner
    00025  3    IPC@CHIP  1.2         23.02.2001 11:59:14  Ernest Schlösser Added a few
    00026       comments
    00027  2    IPC@CHIP  1.1         15.02.2001 15:16:52  Christoph Stoidner
    00028  1    IPC@CHIP  1.0         14.02.2001 16:09:19  Christoph Stoidner
    00029 $
    00030 *****************************************************************************/
    00031
    00032
    00033 #ifndef HWAPI_H
    00034 #define HWAPI_H
    00035
    00036 /***************************************************************************/
    00037 // Typedefs
    00038 /***************************************************************************/
    00039 typedef void interrupt (*InterruptHandler)(void);
    00040
    00041 /***************************************************************************/
    00042 // Defines
    00043 /***************************************************************************/
    00044 #ifdef _MSC_VER /* If Microsoft C Compiler is used, define new FP_SEG and FP_OFF Macro */
    00045   #ifdef FP_SEG
    00046       #undef FP_SEG
    00047   #endif
    00048   #define FP_SEG(ptr)    ((unsigned int)(((unsigned long)ptr)>>16))
    00049
    00050   #ifdef FP_OFF
    00051       #undef FP_OFF
    00052   #endif
    00053   #define FP_OFF(ptr)    ((unsigned int)(((unsigned long)ptr)&0xFFFF))
    00054 #endif
    00055
    00056
    00057 /***************************************************************************/
    00058 // Hardware API Function Numbers
    00059 /***************************************************************************/
    00060 // PFE Services
    00061 #define PFE_ENABLE_DATA_BUS             0x80
    00062 #define PFE_ENABLE_NON_MULTI_ADDR_BUS   0x81
    00063 #define PFE_ENABLE_PIO                  0x82
    00064 #define PFE_ENABLE_PCS                  0x83
    00065 #define PFE_ENABLE_EXTERNAL_IRQ         0x84
    00066 #define PFE_ENABLE_EXTERNAL_TIMER       0x85
    00067 #define PFE_SET_EDGE_LEVEL_INTR_MODE    0x86
    00068 #define PFE_ENABLE_PWD                  0x87
    00069 #define PFE_ENABLE_EXTERNAL_DMA         0x88
    00070 #define PFE_ENABLE_INT_CASCADE_MODE     0x89
    00071 // HAL Services
    00072 #define HAL_SET_INT0_VECT               0x10
    00073 #define HAL_READ_DATA_BUS               0x80
    00074 #define HAL_WRITE_DATA_BUS              0x81
    00075 #define HAL_READ_PIO                    0x82
    00076 #define HAL_WRITE_PIO                   0x83
    00077 #define HAL_INSTALL_ISR                 0x84
    00078 #define HAL_INIT_TIMER                  0x85
    00079 #define HAL_START_TIMER                 0x86
    00080 #define HAL_STOP_TIMER                  0x87
    00081 #define HAL_READ_TIMER_COUNT            0x88
    00082 #define HAL_WRITE_TIMER_COUNT           0x89
    00083 #define HAL_GET_FREQUENCIES             0x8A
    00084 #define HAL_SET_DUTY_CYCLE_WAVEFORM     0x8B
    00085 #define HAL_READ_SPECIFIC_PIO           0x8C
    00086 #define HAL_WRITE_SPECIFIC_PIO          0x8D
    00087 #define HAL_GIVE_EOI                    0x8E
    00088 #define HAL_GET_SET_WATCHDOG_MODE       0x90
    00089 #define HAL_REFRESH_WATCHDOG            0x91
    00090 #define HAL_BLOCK_READ_DATA_BUS         0xA0
    00091 #define HAL_BLOCK_WRITE_DATA_BUS        0xA1
    00092 #define HAL_START_DMA                   0xB0
    00093 #define HAL_STOP_DMA                    0xB1
    00094 #define HAL_GET_DMA_INFO                0xB2
    00095 #define HAL_INIT_REST_NON_VOLATILE_DATA 0xC0
    00096 #define HAL_SAVE_NON_VOLATILE_DATA      0xC1
    00097 #define HAL_GET_REBOOT_REASON           0xC2
    00098
    00099
    00100 /***************************************************************************/
    00101 // Interrupt Vectors
    00102 /***************************************************************************/
    00103 #define PFE_INT  0xA2
    00104 #define HAL_INT  0xA1
    00105
    00106
    00107 /***************************************************************************/
    00108 // General definitions
    00109 /***************************************************************************/
    00110 #define DIRECT_IO
    00111
    00112
    00113 #define PIO_I      1
    00114 #define PIO_IPU    2
    00115 #define PIO_IPD    3
    00116 #define PIO_O1     4
    00117 #define PIO_O0     5
    00118
    00119 #define A0         0
    00120 #define A1         1
    00121 #define A2         2
    00122
    00123 #define GET_FRQ_PROCESSOR  0
    00124 #define GET_FRQ_TIMER      1
    00125 #define GET_FRQ_MAX_BAUD   2
    00126 #define GET_FRQ_PWD        3
    00127
    00128 #ifdef DIRECT_IO
    00129  #define hal_inportb(x)      inportb(x)
    00130  #define hal_outportb(x,y)   outportb(x,y)
    00131 #else
    00132  #define hal_inportb(x)      hal_read_bus(x,0xFFFF,0x0000)
    00133  #define hal_outportb(x,y)   hal_write_bus(x,y,0xFFFF,0x0000)
    00134 #endif
    00135
    00136 #define hal_inportb_block    hal_readblock_bus
    00137 #define hal_outportb_block   hal_writeblock_bus
    00138
    00139
    00140 // DMA Control registers Bits
    00141 #define DMA_PRIO      (1<<0)
    00142 #define DMA_SYNCSRC   (1<<1)
    00143 #define DMA_SYNCDEST  (1<<2)
    00144 #define DMA_DOINTR    (1<<3)
    00145 #define DMA_SRCINC    (1<<5)
    00146 #define DMA_SRCDEC    (1<<6)
    00147 #define DMA_SRCIO     (0)     /* Bit 7  equal to null */
    00148 #define DMA_SRCMEM    (1<<7)
    00149 #define DMA_DESTINC   (1<<8)
    00150 #define DMA_DESTDEC   (1<<9)
    00151 #define DMA_DESTIO    (0)     /* Bit 10 equal to null */
    00152 #define DMA_DESTMEM   (1<<10)
    00153 #define DMA_WORDTRANS (1<<11)
    00154
    00155 // Dma channels
    00156 #define DMA_CH0       0
    00157 #define DMA_CH1       1
    00158
    00159
    00160
    00161 /***************************************************************************/
    00162 // Datatypes
    00163 /***************************************************************************/
    00164
    00165 // DMA Info Struct
    00166 typedef struct
    00167 {
    00168    unsigned count;
    00169    union
    00170    {
    00171      void     *mem;
    00172      unsigned  io;
    00173    } src;
    00174
    00175    union
    00176    {
    00177      void     *mem;
    00178      unsigned  io;
    00179    } dest;
    00180
    00181    unsigned ctrl_reg;
    00182 } Dma_Info;
    00183
    00184 // Non Valotile Data
    00185 #ifndef MAX_RETENTIVE_AREAS
    00186
    00187  #define MAX_RETENTIVE_AREAS 10
    00188 #endif
    00189 typedef struct _REMOP
    00190 {
    00191     unsigned entries; // number of entries in struct REMOP_ENTRY x[]
    00192     unsigned segment; // common segment address
    00193
    00194     struct REMOP_ENTRY
    00195     {
    00196         unsigned offs;      // offset address
    00197         unsigned size;      // number of bytes (must be <= maxsize)
    00198         unsigned maxsize;   // maximal number of bytes
    00199         unsigned elemsize;  // number of bytes per data element
    00200         unsigned distance;  // distance to next data element (must be >= elemsize)
    00201     }x[MAX_RETENTIVE_AREAS];
    00202 } Remop;
    00203
    00204
    00205
    00206 /***************************************************************************/
    00207 // Prototyps
    00208 /***************************************************************************/
    00209
    00210 // ********** PFE Functiuons **************************
    00211 void pfe_enable_bus (unsigned mask, unsigned char ale);
    00212 void pfe_enable_adr (unsigned char adr);
    00213 void pfe_enable_pcs (unsigned char pcs);
    00214 void pfe_enable_int (unsigned char irq);
    00215 void pfe_enable_timer (unsigned mode);
    00216 void pfe_enable_pio (unsigned pio, unsigned char mode);
    00217 void pfe_get_pio_state (unsigned *wPio, unsigned *wInp, unsigned *wOut);
    00218 void pfe_set_edge_level_intr_mode(unsigned char mode, unsigned mask);
    00219 void pfe_enable_pwd(void);
    00220 int pfe_enable_external_dma( unsigned char channel);
    00221 void pfe_enable_int_cascade_mode(void);
    00222
    00223
    00224 // ************ HAL functions ************************
    00225 unsigned char hal_read_bus (unsigned adr, unsigned wAND, unsigned wXOR);
    00226 void hal_write_bus (unsigned adr, unsigned char value, unsigned wAND, unsigned wXOR);
    00227 void hal_readblock_bus (unsigned adr0, unsigned adr1, unsigned char *buf, unsigned cnt);
    00228 void hal_writeblock_bus (unsigned adr0, unsigned adr1, unsigned char *buf, unsigned cnt);
    00229 //  PIO functions
    00230 void hal_get_pio_output_state (unsigned *pins, unsigned wOut);
    00231 // function 0x82: returns the value of PIO 0..13
    00232 unsigned hal_read_pios (unsigned wAND, unsigned wXOR);
    00233 void     hal_write_pios (unsigned value, unsigned wAND, unsigned wXOR);
    00234
    00235 // function 0x8C: read specifik pio pin 0..13, ret 0 if low
    00236 unsigned char hal_read_pio (unsigned char pio);
    00237 void          hal_write_pio (unsigned char pio, unsigned value);
    00238
    00239 InterruptHandler hal_install_isr (unsigned irq, unsigned count, InterruptHandler handler);
    00240 void hal_init_timer (unsigned char timer, unsigned mode, unsigned divider);
    00241 void hal_start_timer (unsigned char timer);
    00242 void hal_stop_timer (unsigned char timer);
    00243 unsigned hal_read_timer_count (unsigned char timer, unsigned far *maxcount);
    00244 void hal_write_timer_count (unsigned char timer, unsigned counter);
    00245 unsigned char hal_set_watchdog_mode (unsigned char mode);
    00246 void hal_refresh_watchdog (void);
    00247
    00248 unsigned long hal_get_frequencies( unsigned char frq );
    00249 void hal_set_duty_cycle_waveform( unsigned char timer, int mode,
    00250                                   unsigned clock_divider );
    00251 void hal_give_eoi( unsigned char intr_no );
    00252
    00253 // DMA Functions
    00254 void hal_start_dma( unsigned char channel, Dma_Info *dmaInfo );
    00255 int hal_stop_dma( unsigned char channel );
    00256 int hal_get_dma_info( unsigned char channel, Dma_Info *dmaInfo );
    00257
    00258 // NMI
    00259 int hal_init_non_volatile_data( Remop *remop );
    00260 void hal_save_non_volatile_data(void);
    00261
    00262 int hal_get_reboot_reason(void);
    00263
    00264
    00265 #endif
    00266