/* GNU license implied
    Copyright (C) 2001 Matthias Schoeldgen DC7UR (m.schoeldgen@b-cool.de)
    Initializes most of the hardware of MC68EZ328 for use with the robot    
    */	
    
#include <asm/MC68EZ328.h> 
#include <stdlib.h>
/* #include <string.h>
*/
#include <stdio.h>
void inithard(void)
{
    printf("Initing ");
/* Sharp distance sensor */
    PDSEL |= 0x03;	/* port usage */
    PDDIR |= 0x02;	/* is output */
    PDDIR &= 0xFE;      /* data from sensor */    
    printf("Distance ");

/*  PWM Modulator */
    PBDIR |= 0x80 ; /* select output for PB7 */
    PBSEL &= 0x7f ; /* internal function */
    PWMC = 0x4f12 ; /* gives roughly 200 Hz */
    PWMP = 0xff ;
    printf("PWM ");
/* SPI master */
    PESEL &= 0xf8;	/* internal function of port bits E */
    SPIMCONT = 0x2007 ;  /* high data rate, disable, no irq, 8bits */
    SPIMCONT |= 0x0200 ; /* enable spim */
    printf("SPI \n");
}

int main(int argc, char *argv[])
{
unsigned int val;
switch (argc) {
    case 1:	inithard();
		break;
    default : 	printf("Inits Robot hardware. usage: inithard\n");
		break;
	}
exit (0);
}
