天天看點

蜂鳴器發聲beep

#include <stdlib.h>

#include <stdio.h>

int main(int argc, char *argv[]) {

 printf("\a");

 printf("Welcome to the Momentics IDE\n");

 return EXIT_SUCCESS;

}

#include <stdlib.h>

#include <stdio.h>

#include <x86/inout.h>

#include <sys/neutrino.h>

#include <unistd.h>

int main()

{

int system_control=0;

unsigned long i;

unsigned long kbd, clk;

ThreadCtl(_NTO_TCTL_IO, 0);

kbd = mmap_device_io(4,0x60);

clk = mmap_device_io(4,0x40);

// turn . bits 0 & 1 of kbd 0x61

system_control=in8(kbd + 1);

out8(kbd + 1,system_control | 0x03);

// load control word for 8254

out8(clk + 3, 0xb7); // bcd count, square wave,

// r/w lsb then msb, channel 2

// load counts

// to get 440Hz tone, divide 8254 clock (1.1892 MHz) by 2702

out8(clk + 2,0x02); // lsb count

out8(clk + 2,0x27); // msb count - remember, we're using BCD

// pause a bit...

sleep(1);   //usleep(100000); timer問題10ms不響

// shut it off

out8(kbd + 1,system_control & 0xfc);

return(0);

繼續閱讀