Fork me on GitHub

root/kernel/pit.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. pit_beep_on
  2. pit_beep_off
  3. pit_init

   1 /*
   2  * fiwix/kernel/pit.c
   3  *
   4  * Copyright 2018, Jordi Sanfeliu. All rights reserved.
   5  * Distributed under the terms of the Fiwix License.
   6  */
   7 
   8 #include <fiwix/asm.h>
   9 #include <fiwix/pit.h>
  10 
  11 void pit_beep_on(void)
  12 {
  13         outport_b(MODEREG, SEL_CHAN2 | LSB_MSB | SQUARE_WAVE | BINARY_CTR);
  14         outport_b(CHANNEL2, (OSCIL / BEEP_FREQ) & 0xFF);        /* LSB */
  15         outport_b(CHANNEL2, (OSCIL / BEEP_FREQ) >> 8);          /* MSB */
  16         outport_b(PS2_SYSCTRL_B, inport_b(PS2_SYSCTRL_B) | ENABLE_SDATA | ENABLE_TMR2G);
  17 }
  18 
  19 void pit_beep_off(unsigned int unused)
  20 {
  21         outport_b(PS2_SYSCTRL_B, inport_b(PS2_SYSCTRL_B) & ~(ENABLE_SDATA | ENABLE_TMR2G));
  22 }
  23 
  24 void pit_init(unsigned short int hertz)
  25 {
  26         outport_b(MODEREG, SEL_CHAN0 | LSB_MSB | RATE_GEN | BINARY_CTR);
  27         outport_b(CHANNEL0, (OSCIL / hertz) & 0xFF);    /* LSB */
  28         outport_b(CHANNEL0, (OSCIL / hertz) >> 8);      /* MSB */
  29 }

/* [previous][next][first][last][top][bottom][index][help] */