Newer
Older
Scratch / ubix3 / src / sys / pit.c
@Christopher W. Olsen Christopher W. Olsen on 25 Oct 2019 743 bytes Scratch
/**************************************************************************************
$Id: pit.c,v 1.10 2002/04/20 02:59:46 reddawg Exp $


**************************************************************************************/

#include <ubixos/io.h>
#include <ubixos/pit.h>

void init_pit(float h, unsigned char channel) {
  unsigned int temp=0;
  temp = 1193180/h;
  outportb(TMR_CTRL, (channel*0x40) + TMR_BOTH + TMR_MD3);
  outportb((0x40+channel), (unsigned char) temp);
  outportb((0x40+channel), (unsigned char) (temp>>8));
  }

unsigned int pit_getchannel(unsigned char channel) {
  unsigned int x=0;
  outportb(TMR_CTRL, (channel*0x40) + TMR_LATCH);
  x = inportb(0x40+channel);
  x += (inportb(0x40+channel) << 8);
  return x;
  }