Пример #1
0
void beep(double freq, double duration)
{
  beep_init();

  /* If different from last call, re-create the sine wave */
  beep_buffer_generate_sine_data(&(g_beep.buffer), freq, duration);

  if (!ao_play(g_beep.device, g_beep.buffer.data, g_beep.buffer.len)) {
    fputs("error rendering sound sample, restarting audio system\n", stderr);
    beep_shutdown();
    beep_init();
  }
}
Пример #2
0
//开机初始化
void All_Init( void )
{
	const uint32_t NewDeviationAddr = 0x4000;
	
	/* BootLoad引导程序时,必须在Main中添加,同时更改“魔术棒--Target选项卡的ROM偏移地址” */
	NVIC_SetVectorTable(NVIC_VectTab_FLASH,NewDeviationAddr);				
	
	/* 外设初始化 */
	lcd_init();   
	rtc_init(); 
	led_init(); 	 
	uart3_init(BAUD_38400);
	print_init();	//波特率19200
	timeout_init();
	TIM5_TimeoutInit();	
	link_init(); 
	tf_init();
	eep_init(); 
	delay_init_t2();
 	beep_init();
	SysTick_Config(SYSTICK_10MS);
	
//	PrintSystemParameter();	//串口打印系统参数信息,用于调试
	
	#ifdef ENABLE_BEEP
		BEEP_START();
	#endif
		
	set_page(system_init);
}
Пример #3
0
/**********************************************************************
*	函 数 名: timer_init
*	功能说明: 定时器初始化,使用定时器3
*	形    参:  Period自动重装载值,Prescale预分频值
*	返 回 值:  无
**********************************************************************/
void timer_init(uint16_t Period,uint16_t Prescale)
{
	TIM_TimeBaseInitTypeDef TIM_TimeBaseInitStructure;
	NVIC_InitTypeDef NVIC_InitStructure;
	
	RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE);  			//使能TIM3时钟
	
	TIM_TimeBaseInitStructure.TIM_Period = Period; 					//自动重装载值
	TIM_TimeBaseInitStructure.TIM_Prescaler=Prescale;  				//定时器分频
	TIM_TimeBaseInitStructure.TIM_CounterMode=TIM_CounterMode_Up; 	//向上计数模式
	TIM_TimeBaseInitStructure.TIM_ClockDivision=TIM_CKD_DIV1; 
	
	TIM_TimeBaseInit(TIM3,&TIM_TimeBaseInitStructure);				//初始化TIM3
	
	
	TIM_ClearFlag(TIM3,TIM_IT_Update);								//清除更新标志
	TIM_SetCounter(TIM3,0);																					//设置定时器值
	 
	TIM_ITConfig(TIM3,TIM_IT_Update,ENABLE); 						//允许定时器3更新中断
	TIM_Cmd(TIM3,ENABLE); 																					//使能定时器3
	
	NVIC_InitStructure.NVIC_IRQChannel=TIM3_IRQn; //定时器3中断
	NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0x01; 		//抢占优先级1
	NVIC_InitStructure.NVIC_IRQChannelSubPriority=0x00; 			//子优先级3
	NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;
	NVIC_Init(&NVIC_InitStructure); 
	
	beep_init();
} 
Пример #4
0
int beep_open(struct inode *inode, struct file *filp)
{
	beep_init();
	printk(KERN_INFO "test if it arrive here! 62\n");
	printk(KERN_INFO "beep opened\n");
	return 0;
}
Пример #5
0
void board_init(void)
{
  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
  timer2_init();
  timer14_init();
  Usart_Init(USART2,9600);
  send_data(USART2, "uart2 is OK!\r\n", strlen("uart2 is OK!\r\n"));
  //不同的传感器的引脚及用到的板级外设不同
  //sensor_init();
#if defined (BEEP)
  //蜂鸣器用作调试设备
  beep_init();
  Delay(20);
  BEEP_OFF();
#endif
#if defined (DEBUG)
  //串口用作调试端口
  Usart_Init(DEBUG_UART,115200);
  send_data(DEBUG_UART, "uart is OK!\r\n", strlen("uart is OK!\r\n"));
#endif
#if defined (EEPROM)
  //24cxx IIC接口初始化
  IIC_Init();
#endif
} 
Пример #6
0
static void system_init(void) {
    delay_init();
    led_init();
    beep_init();
    key_init();
    uart_init();
    lcd_init();
    sram_init();
    time_init();
    flash_inside_init();
    flash_outside_init();
    
    led_power_on();
    lcd_on();
}
Пример #7
0
/*
 * 主函数, 该程序主要测试中断系统的基本初始化
 * 使用UART RX中断实现CONSOLE程序,并完成了 LED ON, LED OFF, BEEP ON,BEEP OFF的功能
 */
int main (void)
{
	led_init ();
	beep_init() ;
	init_uart0 ();

	VIC2VECTADDR.VIC2VECTADDR23 = (unsigned int)adc_irq_handler;
	//通道0
	ADC.ADCMUX = 0 ;
				  //12BIT      预分频              分频值             读转换模式
	ADC.ADCCON = (1 << 16) | (1 << 14) | (65 << 6) | (0 << 1);

	VIC2INTERRUPT.VIC2INTENABLE = VIC2INTERRUPT.VIC2INTENABLE | (1 << 23);

	while (1){
		ADC.ADCCON = ADC.ADCCON | (1 << 0);
		while (flag == 0);
		flag = 0;
		adval = adval * 3300 / 4096;
		printf ("vol = %d mv\r\n", adval);
	}
	return 0 ;
}
Пример #8
0
int
main (int argc, char **argv)
{
  int ret;
  int c;

  FILE *pidfile;
  struct utsname sysinfo;

  machine_type machine;

  while ((c = getopt(argc, argv, "fdv")) != -1)
    {
      switch (c)
	{
	  case 'f':
	    console = 1;
	    break;

	  case 'd':
	    debug = 1;
	    console = 1;
	    break;

	  case 'v':
	    printf("pommed v" M_VERSION " Apple laptops hotkeys handler\n");
	    printf("Copyright (C) 2006-2011 Julien BLACHE <*****@*****.**>\n");

	    exit(0);
	    break;

	  default:
	    usage();

	    exit(1);
	    break;
	}
    }

  if (geteuid() != 0)
    {
      logmsg(LOG_ERR, "pommed needs root privileges to operate");

      exit(1);
    }

  if (!console)
    {
      openlog("pommed", LOG_PID, LOG_DAEMON);
    }

  logmsg(LOG_INFO, "pommed v" M_VERSION " Apple laptops hotkeys handler");
  logmsg(LOG_INFO, "Copyright (C) 2006-2011 Julien BLACHE <*****@*****.**>");

  /* Load our configuration */
  ret = config_load();
  if (ret < 0)
    {
      exit(1);
    }

  /* Identify the machine we're running on */
  machine = check_machine();
  switch (machine)
    {
      case MACHINE_MAC_UNKNOWN:
	logmsg(LOG_ERR, "Unknown Apple machine");

	exit(1);
	break;

      case MACHINE_UNKNOWN:
	logmsg(LOG_ERR, "Unknown non-Apple machine");

	exit(1);
	break;

      case MACHINE_ERROR:
	exit(1);
	break;

      default:
	if (machine < MACHINE_LAST)
	  {
#ifdef __powerpc__
	    mops = &pb_mops[machine];
#else
	    mops = &mb_mops[machine];
#endif /* __powerpc__ */
	  }
	break;
    }

  /* Runtime sanity check: catch errors in the mb_mops and pb_mops arrays */
  if (mops->type != machine)
    {
      logmsg(LOG_ERR, "machine_ops mismatch: expected %d, found %d", machine, mops->type);

      exit(1);
    }

  if (debug)
    {
      ret = uname(&sysinfo);

      if (ret < 0)
	logmsg(LOG_ERR, "uname() failed: %s", strerror(errno));
      else
	logdebug("System: %s %s %s\n", sysinfo.sysname, sysinfo.release, sysinfo.machine);
    }

  ret = evloop_init();
  if (ret < 0)
    {
      logmsg(LOG_ERR, "Event loop initialization failed");
      exit (1);
    }

  ret = mops->lcd_backlight_probe();
  if (ret < 0)
    {
      logmsg(LOG_ERR, "LCD backlight probe failed, check debug output");

      exit(1);
    }

  ret = evdev_init();
  if (ret < 1)
    {
      logmsg(LOG_ERR, "No suitable event devices found");

      exit(1);
    }

  kbd_backlight_init();

  ret = audio_init();
  if (ret < 0)
    {
      logmsg(LOG_WARNING, "Audio initialization failed, audio support disabled");
    }

  ret = mbpdbus_init();
  if (ret < 0)
    {
      logmsg(LOG_WARNING, "Could not connect to DBus system bus");
    }

  power_init();

  if (!console)
    {
      /*
       * Detach from the console
       */
      if (daemon(0, 0) != 0)
	{
	  logmsg(LOG_ERR, "daemon() failed: %s", strerror(errno));

	  evdev_cleanup();

	  exit(1);
	}
    }

  pidfile = fopen(PIDFILE, "w");
  if (pidfile == NULL)
    {
      logmsg(LOG_WARNING, "Could not open pidfile %s: %s", PIDFILE, strerror(errno));

      evdev_cleanup();

      exit(1);
    }
  fprintf(pidfile, "%d\n", getpid());
  fclose(pidfile);

  /* Spawn the beep thread */
  beep_init();

  signal(SIGINT, sig_int_term_handler);
  signal(SIGTERM, sig_int_term_handler);


  do
    {
      ret = evloop_iteration();
    }
  while (ret >= 0);

  evdev_cleanup();

  beep_cleanup();

  mbpdbus_cleanup();

  kbd_backlight_cleanup();

  power_cleanup();

  evloop_cleanup();

  config_cleanup();

  logmsg(LOG_INFO, "Exiting");

  if (!console)
    closelog();

  unlink(PIDFILE);

  return 0;
}
Пример #9
0
/*
 * bbc_beep_attach:
 */
static int
bbc_beep_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
{
	int		instance;		/* Instance number */

	/* Pointer to soft state */
	bbc_beep_state_t	*bbc_beeptr = NULL;

	BBC_BEEP_DEBUG1((CE_CONT, "bbc_beep_attach: Start"));

	switch (cmd) {
		case DDI_ATTACH:
			break;
		case DDI_RESUME:
			return (DDI_SUCCESS);
		default:
			return (DDI_FAILURE);
	}

	/* Get the instance and create soft state */
	instance = ddi_get_instance(dip);

	if (ddi_soft_state_zalloc(bbc_beep_statep, instance) != 0) {

		return (DDI_FAILURE);
	}

	bbc_beeptr = ddi_get_soft_state(bbc_beep_statep, instance);

	if (bbc_beeptr == NULL) {

		return (DDI_FAILURE);
	}

	BBC_BEEP_DEBUG1((CE_CONT, "bbc_beeptr = 0x%p, instance %x",
	    (void *)bbc_beeptr, instance));

	/* Save the dip */
	bbc_beeptr->bbc_beep_dip = dip;

	/* Initialize beeper mode */
	bbc_beeptr->bbc_beep_mode = BBC_BEEP_OFF;

	/* Map the Beep Control and Beep counter Registers */
	if (bbc_beep_map_regs(dip, bbc_beeptr) != DDI_SUCCESS) {

		BBC_BEEP_DEBUG((CE_WARN, \
		    "bbc_beep_attach: Mapping of bbc registers failed."));

		bbc_beep_cleanup(bbc_beeptr);

		return (DDI_FAILURE);
	}

	(void) beep_init((void *)dip, bbc_beep_on, bbc_beep_off, bbc_beep_freq);

	/* Display information in the banner */
	ddi_report_dev(dip);

	BBC_BEEP_DEBUG1((CE_CONT, "bbc_beep_attach: dip = 0x%p done",
	    (void *)dip));

	return (DDI_SUCCESS);
}
Пример #10
0
void setup()
{
	beep_init();
}
Пример #11
0
int main(void)
{
//	EXT_MEM_INIT;
	
	usart0_init(USART_RS485_SLAVE, 38400);
	usart0_setprotocol_modbus();
	usart1_init(USART_RS232, 115200);
	USART1_SET_8N1;
	USART1_RX_INT_DISABLE;

	timer_init();
	kbd_init();
	shift_init();
	sensor_init();
	menu_init();
	menu_items_init();

	beep_init();
	
	GLOBAL_INT_ENABLE;

	beep_ms(1000);
	_delay_ms(500);
	beep_ms(200);
	_delay_ms(200);
	beep_ms(200);
	_delay_ms(200);

	lcd_init();

	for (;;)
	{
		//do_kbd();
		do_lcd();
		do_shift();
		do_sensor();
		
		menu_doitem();

		process_usart();
		process_soft_controls();
		process_siren();
		//process_foil();
		//process_kbd();
		
		// simple process foil
		
		soft_sensors = sensors;
		
		if (TEST_SOFT_CONTROL(SOFT_CONTROL_BUNKER_MOTOR) &&
			TEST_SENSOR(SENSOR_END_OF_FOIL))
			
			SOFT_CONTROL_OFF(SOFT_CONTROL_BUNKER_MOTOR);
/*			
		if (!TEST_SENSOR(SENSOR_END_OF_FOIL) &&
			TEST_SENSOR(SENSOR_SEC_REEL))
			
			SOFT_CONTROL_ON(SOFT_CONTROL_BUNKER_MOTOR);
*/
	}
	return 0;
}
Пример #12
0
//-----------------------------------------------
void beep_hndl(void) 
{ 
static char bcnt;
bcnt++; 
if(bcnt>9)bcnt=0;
//bU_BAT2REL_AV_BAT=0;
if(avar_ind_stat)beep_init(0x33333333,'R');


else if ( (((bat[0]._Ub<(USIGN*10))&&(BAT_IS_ON[0]==bisON))||((bat[1]._Ub<(USIGN*10))&&(BAT_IS_ON[1]==bisON)))) 
	{
	if(!bSILENT)beep_init(0x01010101,'R');
	//bU_BAT2REL_AV_BAT=1;
	}

else if ( (((bat[0]._Ib<(-IKB))&&(BAT_IS_ON[0]==bisON))||((bat[1]._Ib<(-IKB))&&(BAT_IS_ON[1]==bisON)))) 
	{
	if(!bSILENT)beep_init(0x00010001,'R');
	//bU_BAT2REL_AV_BAT=1;
	}

else if ( ((bat[0]._temper_stat&0x03)||(bat[1]._temper_stat&0x03)) )
	{
	if(!bSILENT) beep_init(0x00000005,'R');
	}


else 
	{
	beep_init(0x00000000,'S');
	bSILENT=0;
	} 


//if(!avar_ind_stat)beep_init(0x00000000,'R');

/*if(K[MNL]==ON)
	{ */
//if(((av_beep&0xffff)&&(ind!=iK)&&(ind!=iTst))
//	/*||((!T_EXT_ZVUK_EN[0])&&((tout_stat[0]==tMIN)||(tout_stat[0]==tMAX)))*/)beep_init(0x55555555,'R'); 

//else if(bUrazr&&(!bUOFF))beep_init(0x00010001,'R');

//else if(bIrazr&&(cnt_beep==0))beep_init(0x01010101,'R');

/*
else if(bTsi||bTsb)
	{
	if(!bcnt)beep_init(0x00000001,'O');
     }

else if(bIbr) beep_init(0x00000001,'R');
*/


//else beep_init(0x00000000,'S');



bU_BAT2REL_AV_BAT=0;
#ifdef UKU206_220
if  (((bat[0]._Ub<(USIGN*10))&&(BAT_IS_ON[0]==bisON))) 
	{
	bU_BAT2REL_AV_BAT=1;
	}
#endif

}