int beep_bufout(cw_length * cw_len, int fd, char * buf) { int len, co; len = (int)strlen(buf); for(co = 0; co < len; co++){ if(buf[co] == cw_len->short_p){ beep_on(fd, cw_len->sp, cw_len->freq); beep_sleep(cw_len->ps); } else if(buf[co] == cw_len->long_p){ beep_on(fd, cw_len->lp, cw_len->freq); beep_sleep(cw_len->ps); } else if(buf[co] == cw_len->break_p){ beep_sleep(cw_len->cs); #ifdef LIBCW_BUG printf("LIBCW_BUG: beep_bufout(): break time %d\n", cw_len->cs); #endif } else if(buf[co] == cw_len->wbreak_p){ beep_sleep(cw_len->ws); #ifdef LIBCW_BUG printf("LIBCW_BUG: beep_bufout(): wbreak time %d\n", cw_len->ws); #endif } else{ } } return len; }
// BEEP 再生 void pro100_beep(UINT freq, UINT msecs) { beep_on(); beep_set_freq(freq); pro100_sleep(msecs); beep_off(); }
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 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 acpi_pm1_sleep (u32 v) { struct facs *facs; #ifdef ACPI_DSDT bool m[6]; int i; u8 n; #endif #ifdef ACPI_DSDT n = (v & PM1_CNT_SLP_TYPX_MASK) >> PM1_CNT_SLP_TYPX_SHIFT; for (i = 0; i <= 5; i++) { if (acpi_dsdt_system_state[i][0] && acpi_dsdt_system_state[i][1] == n) m[i] = true; else m[i] = false; } if (!m[2] && !m[3]) return; #endif facs = acpi_mapmem (facs_addr, sizeof *facs); if (IS_STRUCT_SIZE_OK (facs->length, facs, facs->x_firmware_waking_vector)) facs->x_firmware_waking_vector = 0; if (IS_STRUCT_SIZE_OK (facs->length, facs, facs->firmware_waking_vector)) facs->firmware_waking_vector = 0xFFFF0; else for (;;); /* FIXME: ERROR */ /* DEBUG */ /* the computer is going to sleep */ /* most devices are suspended */ /* vmm can't write anything to a screen here */ /* vmm can't input from/output to a keyboard here */ /* vmm can beep! */ beep_on (); beep_set_freq (880); usleep (500000); beep_set_freq (440); usleep (500000); beep_set_freq (880); usleep (500000); beep_set_freq (440); usleep (500000); beep_set_freq (880); usleep (500000); beep_set_freq (440); usleep (500000); beep_set_freq (880); acpi_poweroff (); }
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(); //init_key(); 轮循初始化 //init_interrupt_for_key(); //中断的方式 led_off_all(); if(flag){ led_on_all(); beep_on(); } int i; while(1){ } 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 MCP39F511Interface::setupPWM(int frequency, int duty_cycle) { int calculated_duty_cycle; double calculated_period; calculated_period = 2 * MCP_PWM_PRESCALER * frequency; calculated_period = (1 /(double)MCP39F511_CLOCK_FREQUENCY) * calculated_period; calculated_period = 1 / calculated_period; /* Apply the period part */ mcpCompPeriphReg.PWM_period = ((int)calculated_period & MCP_PWM_PERIOD_PWM_P_MASK) << MCP_PWM_PERIOD_PWM_P_POS; /* Apply the prescaler part */ mcpCompPeriphReg.PWM_period |= (MCP_PWM_REG_PRESCALER & MCP_PWM_PERIOD_PRE_MASK) << MCP_PWM_PERIOD_PRE_POS; /* Apply the duty cycle */ calculated_duty_cycle = duty_cycle; mcpCompPeriphReg.PWM_duty_cycle = (calculated_duty_cycle & MCP_PWM_DUTY_UPPER_MASK) << MCP_PWM_DUTY_UPPER_POS; //duty_cycle * 4 * frequency; mcpCompPeriphReg.PWM_duty_cycle |= (calculated_duty_cycle & MCP_PWM_DUTY_LOWER_MASK) << MCP_PWM_DUTY_LOWER_POS; mcp_comms->enqueTransaction(MCP_COMP_PERIPH_REG_PWM_PERIOD, (u_int8_t*) &mcpCompPeriphReg.PWM_period, sizeof(mcpCompPeriphReg.PWM_period) + sizeof(mcpCompPeriphReg.PWM_duty_cycle), MCP_CMD_REGISTER_WRITE); /* Ensure sounder is off */ beep_on(false); }
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; } } } } }