/*****************************************************************************/
/* File: k-bus.h */
/* Author: Christopher Odenbach */
/* Date: May 1999 */
/* Description: Include file for use of any modules which use the irq6 */
/*****************************************************************************/
#ifndef K_BUS_H
#define K_BUS_H
/*
* includes
*
* these includes are needed
*
*/
#include "bios.h"
#include "math.h"
#include "stdlib.h"
#include "stdio.h"
#include "string.h"
/*
* Global variables
*
* You won't need to use them
*
*/
uint8 module[16], modules = 0;
/*
* init_modules
*
* This function searches through the k-bus and detects modules which
* use the base address xxxx 00 as a status register and who give back a
* value != 32. Invoke once when the program starts.
*
*/
void init_modules()
{
uint8 erg, i, adr;
for (i=0; i<16; i++) {
adr = i*4;
erg = var_get_extension (adr);
if (erg != 32) { /* module is available */
module[modules++] = adr;
printf("Found module at address %i\n",adr);
}
}
}
/*
* irq_routine_module()
*
* When the global interrupt service routine has found out which module
* requested the irq the module specific irq routine is called. Add
* your own irq routine here for new modules as described below.
*
*/
void irq_routine_module (uint8 mod, uint8 status)
{
switch (mod) {
case 0: /* CAN-IR-Module */
irq_routine_ir (status);
break;
/* case 4: another module at base address 4
..
break;
add interrupt routines for new modules here
*/
default:
break;
}
}
/*
* irq_routine()
*
* This is the global interrupt service routine. The interrupt vector
* must point here. The function asks every existing module if it
* requested the interrupt. A non-zero return value means 'yes'. Then
* the function irq_routine_module (described above) is invoked.
*
*/
void irq_routine()
{
uint8 status, i = 0;
boolean ok = FALSE;
while (!ok && (i < modules)) {
status = var_get_extension (module[i]);
if (status != 0) {
ok = TRUE;
irq_routine_module (module[i], status);
}
i++;
}
}
#endif