// BEEP 再生 void pro100_beep(UINT freq, UINT msecs) { beep_on(); beep_set_freq(freq); pro100_sleep(msecs); beep_off(); }
void test_beep(void) { char pressKey; while (1) { printf("Press 'o' to on beep\n"); printf("Press 'f' to off beep\n"); printf("Press 'e' to ending beep operat\n"); printf("Enter you choice: \n"); pressKey = getchar(); printf("\n"); switch (pressKey) { case 'o': beep_on(); break; case 'f': beep_off(); break; } if (pressKey=='e') break; } }
static void report_finish(void) { int i; beep_on(); if (g_timeout) { display_msg("----"); g_rf.tx.err |= err_timeout; g_rf.tx.finish.time = 0; } else g_rf.tx.finish.time = wc_get_time(&g_wc); display_hex(g_rf.tx.finish.time); for (i = REPEAT_MSGS; i; --i) { rfb_send_msg(&g_rf, pkt_finish); wc_delay(&g_wc, REPEAT_MSGS_DELAY); } beep_off(); if (P2IN & XSTATUS) { uart_send_time_hex(g_rf.tx.finish.time); } }
void reset() { // Stop the beeper timer beep_off(); // Stop the break-beam timer beam_timer_stop(); // Reset the speed measurement state speed_state = SPEED_IDLE; holdoff = 0; time_us = 0; reset_auto_power_off(); }
void long_press(int key_num,int num){ if((rEXTINT1 &(7<<num))==0){ if(key_num == 5 || key_num == 6){ led_on_all(); }else{ led_on(key_num); } beep_on(); rEXTINT1 &= ~(7<<num); rEXTINT1 |= 0x4; } else if((rEXTINT1 &(7<<num)) == 0x4){ led_off_all(); beep_off(); rEXTINT1 &= ~(7<<num); } }
static int beep_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { switch(cmd) { case BEEP_ON: beep_on(arg); break; case BEEP_OFF: beep_off(arg); break; default: printk(KERN_WARNING "wrong input\n"); break; } return 0; }
int main() { init_led(); init_beep(); int i; while(1) { for(i=1;i<=4;i++) { beep_on(); led_on(i); delay(0xffff); beep_off(); led_off(i); delay(0xffff); } } return 0; }
void long_press(int key_num,int num){ if((rEXTINT1 &(num))==0){ //低电平触发了中断 if(key_num == 5 || key_num == 6){ led_on_all(); }else{ led_on(key_num); } beep_on(); //改变中断的触发方式为上升沿 rEXTINT1 &= ~(num); rEXTINT1 |= 0x4; } else if((rEXTINT1 &(num)) == 0x4){ //上升沿触发中断 led_off_all(); beep_off(); rEXTINT1 &= ~(num); } }
// Setup working channel static void setup_channel(void) { int r; set_state(st_setup); // Select control channel rf_set_channel(CTL_CHANNEL); // Wait setup message r = rfb_receive_msg(&g_rf, pkt_setup); if (r) { // Show error message rfb_err_msg(r); // Reset itself wc_delay(&g_wc, SHORT_DELAY_TICKS); reset(); } else { // Show channel number display_msg("Ch"); display_set_dp(1); display_hex_(g_rf.rx.p.setup.chan, 2, 2); } beep_on(); // Set working channel rf_set_channel(g_rf.rx.p.setup.chan); // Delay to allow sender to switch to RX wc_delay(&g_wc, SETUP_RESP_DELAY); // Send test message g_rf.tx.setup_resp.li = g_rf.rx.li; rfb_send_msg(&g_rf, pkt_setup_resp); beep_off(); // Reset itself on error or in test mode if (r || (g_rf.rx.p.setup.flags & SETUP_F_TEST)) reset(); }
int main() { init_led(); init_beep(); init_key(); led_off_all(); int i; while(1) { if(i= key_press()){ led_on(i); beep_on(); }else{ led_off_all(); beep_off(); } } return 0; }
/********************************************************************** * 函 数 名: void beep_init(void) * 功能说明: 蜂鸣器初始化 * 形 参: 无 * 返 回 值: 无 **********************************************************************/ void beep_init(void) { GPIO_InitTypeDef GPIO_InitStructure; /* 打开GPIO时钟 */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; /* 设为输出口 */ GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; /* 设为推挽模式 */ GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; /* 上下拉电阻不使能 */ GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; /* IO口最大速度 */ GPIO_InitStructure.GPIO_Pin = BEEP_GPIO_PIN; GPIO_Init(BEEP_GPIO_PORT, &GPIO_InitStructure); beep_off(); beep_cnt=0; beep_time=0; mute_comp=0; beep_comp=0; beep_status=BEEP_STATUS_IDLE; }
void task_3() { while(1) { cpu = OS_GetCPU(); if(connectState == 1) { count1++; count1=count1%2; if(count1 == 0) { msg.len = sizeof(xintiaoBuf); msg.buf = xintiaoBuf; udp.send(&msg); } } if(warningState == 1) { if(turn == 0) { led_on(); beep_on(); } else { led_off(); beep_off(); } if(warningTime > 0) { if(warningTime*2 < count2) { warningState = 0; led_off(); beep_off(); count2 = 0; turn = 0; } count2++; } turn++; turn = turn%2; } else { led_off(); beep_off(); } // uart1.printf("cpu = %0.1f%%\r\n",cpu); // // // mem = OS_GetStackMaxUsage(TASK_1_STK,TASK_1_STK_SIZE); // uart1.printf("task1:mem = %02d%%\r\n",mem); // mem = OS_GetStackMaxUsage(TASK_2_STK,TASK_2_STK_SIZE); // uart1.printf("task2:mem = %02d%%\r\n",mem); // mem = OS_GetStackMaxUsage(TASK_3_STK,TASK_3_STK_SIZE); // uart1.printf("task3:mem = %02d%%\r\n",mem); OS_DelayTimes(500); } }
static void wait_start(void) { for (;;) { int r; // Wait start message monitoring IR at the same time chk_ir_ctx_init(); if (!(r = rfb_receive_valid_msg_(&g_rf, -1, monitor_events))) { switch (g_rf.rx.p.type) { case pkt_start: // Start message received g_timeout = 0; wc_reset(&g_wc); wc_advance(&g_wc, g_rf.rx.p.start.offset); return; case pkt_ping: // Ping message received beep_on(); display_rssi(); wc_delay(&g_wc, SHORT_DELAY_TICKS); rfb_send_msg(&g_rf, pkt_ping); beep_off(); break; case pkt_reset: // Start wants to reinitialize communication reset(); } continue; } if (r == ir_event) { // Need to send IR status to start if (!g_no_ir_reported) { display_msg("noIr"); g_rf.tx.status.flags = sta_no_ir; rfb_send_msg(&g_rf, pkt_status); g_no_ir_reported = 1; } else { display_msg("Good"); g_rf.tx.status.flags = 0; rfb_send_msg(&g_rf, pkt_status); g_no_ir_reported = 0; } continue; } if (r == btn_event) { // Send ping to start for (;;) { wait_btn_release(); beep_on(); display_msg("PIng"); rfb_send_msg(&g_rf, pkt_ping); r = rfb_receive_valid_msg_(&g_rf, pkt_ping, monitor_btn); if (!r) { display_rssi(); beep_off(); break; } if (r == btn_event) { beep_off(); continue; } rfb_err_msg(r); break; } continue; } rfb_err_msg(r); } }
//extern void bsp_RunPer1ms(void); //extern void bsp_RunPer10ms(void); void TIM3_IRQHandler(void) { static uint8_t s_count = 0; uint8_t i; if(TIM_GetITStatus(TIM3,TIM_IT_Update)!=RESET) { TIM_ClearITPendingBit(TIM3,TIM_IT_Update); /* 每隔1ms进来1次 (仅用于 bsp_DelayMS) */ if (s_uiDelayCount > 0) { if (--s_uiDelayCount == 0) { s_ucTimeOutFlag = 1; } } /* 每隔1ms,对软件定时器的计数器进行减一操作 */ for (i = 0; i < TMR_COUNT; i++) { bsp_SoftTimerDec(&s_tTmr[i]); } /* 全局运行时间每1ms增1 */ g_iRunTime++; if (g_iRunTime == 0x7FFFFFFF) /* 这个变量是 int32_t 类型,最大数为 0x7FFFFFFF */ { g_iRunTime = 0; } // bsp_RunPer1ms(); /* 每隔1ms调用一次此函数,此函数在 bsp.c */ /* 全局运行时间每10ms增1 */ if (++s_count >= 10) { s_count = 0; g_iRunTime10ms++; if (g_iRunTime10ms == 0x7FFFFFFF) /* 这个变量是 int32_t 类型,最大数为 0x7FFFFFFF */ { g_iRunTime10ms = 0; } //bsp_RunPer10ms(); /* 每隔10ms调用一次此函数,此函数在 bsp.c */ switch(beep_status) { case BEEP_STATUS_BEEP: { beep_cnt++; if(beep_cnt>=beep_comp) { beep_off(); beep_status=BEEP_STATUS_MUTE; } break; } case BEEP_STATUS_MUTE: { beep_cnt++; if(beep_cnt>=mute_comp) { beep_cnt=0; if(beep_time>1) { beep_time--; beep_status=BEEP_STATUS_BEEP; beep_on(); } else { beep_status=BEEP_STATUS_IDLE; } } break; } case BEEP_STATUS_IDLE: { break; } default: { beep_off(); beep_status=BEEP_STATUS_IDLE; break; } } } } }