KeyLayout::KeyLayout() : Fl_Button(0, 0, 30, 25) { should_show_flag = true; curr_layout = "us"; /* default layout */ img = NULL; box(FL_FLAT_BOX); labelfont(FL_HELVETICA_BOLD); labelsize(10); label("??"); align(FL_ALIGN_CLIP); tooltip(_("Current keyboard layout")); callback(click_cb); foreign_callback_add(window(), PANEL_APPLET_ID, update_flag_cb, this); path = Resource::find_data("icons/kbflags/21x14", RES_SYS_ONLY, NULL); do_key_layout(); update_flag(true); /* TODO: lock this */ keylayout_objects.push_back(this); /* with this, kb layout chages will be catched */ #if HAVE_XKBRULES if(!_XA_XKB_RF_NAMES_PROP_ATOM) _XA_XKB_RF_NAMES_PROP_ATOM = XInternAtom(fl_display, _XKB_RF_NAMES_PROP_ATOM, False); #endif Fl::add_handler(xkb_events); }
void MATRIX_translate(MATRIX *matrix, double dx, double dy) { matrix->dx += dx * matrix->m11 + dy * matrix->m21; matrix->dy += dy * matrix->m22 + dx * matrix->m12; update_flag(matrix); }
void MATRIX_scale(MATRIX *matrix, double sx, double sy) { matrix->m11 *= sx; matrix->m12 *= sx; matrix->m21 *= sy; matrix->m22 *= sy; update_flag(matrix); }
gboolean get_key_win(gpointer data) { AConvert *aconv = (AConvert *)data; XEvent xev; WInfo *info; Window w; info = win_find(aconv->keyboard->win,aconv); if(info) { if(aconv->sxkb->cur_group!=info->cur_group) { XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd, info->cur_group); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); } w=get_active_window(aconv->keyboard->dpy); if(info->win!=w) free_keysym_to_list(aconv); } { if (XPending(aconv->keyboard->dpy)) { XNextEvent (aconv->keyboard->dpy, &xev); switch (xev.type) { case KeyPress: if (xev.xkey.send_event == TRUE) return False; get_key_pres(aconv,&xev); info = win_find(aconv->keyboard->win,aconv); if(info) auto_convert_text(aconv,info); break; case DestroyNotify: if((xev.xdestroywindow.event == aconv->keyboard->root)) break; /* XGetInputFocus (aconv->keyboard->dpy,&w, &(aconv->keyboard->cur_status)); DEBUG_MSG("DestroyNotify ID %#x == ID %#x ++ ID %#x == ID %#x == ID %#x \n",(unsigned int) aconv->keyboard->win,(unsigned int)info->win,(unsigned int)w,(unsigned int)xev.xdestroywindow.window,(unsigned int)xev.xdestroywindow.event);*/ info = win_find(xev.xdestroywindow.event,aconv); if (info) { //printf ("Dest window: ID %#x \n",(unsigned int)info->win); win_free(info,aconv); } break; } } } return TRUE; }
void xConvert_text_eng (gpointer data,WInfo *info) { int i=0; int mod=0; int slen; AConvert *aconv = (AConvert *)data; if((aconv==NULL)||(info==NULL)) return; slen =aconv->keyboard->gstr->len;//g_list_length (info->ks); if(slen<=0) { free_keysym_to_list(aconv); return ; } for (i = 0; i <= aconv->sxkb->ngroups; i++) { if ((g_strcasecmp(aconv->sxkb->group2info[i]->name, "English") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "US/ASCII") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "en_US") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "Maltese (US layout)") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "U.S. English") == 0)) break; } info->cur_group=i; mod=(8192*i); XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd,i); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); delete_char_in_win(info->win,aconv->keyboard->iterator); backspace_char_in_win(info->win,slen-aconv->keyboard->iterator); aconv->keyboard->iterator=0; { GList *p = g_list_first (aconv->keyboard->ks); while (p) { Skeysym *sks=(Skeysym *)p->data; send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+sks->mod); p = g_list_next (p); } } }
void xConvert_text (gpointer data) { int mod=0; size_t slen; AConvert *aconv = (AConvert *)data; if(aconv==NULL) return; aconv->keyboard->win=get_active_window(aconv->keyboard->dpy); WInfo *info = win_find(aconv->keyboard->win,aconv); if (!info) return; slen =aconv->keyboard->gstr->len;//g_list_length (info->ks); if(slen<=0) { free_keysym_to_list(aconv); return ; } if(info->cur_group==(aconv->sxkb->ngroups-1)) info->cur_group=0; else if (info->cur_group < (aconv->sxkb->ngroups-1)) info->cur_group++; else info->cur_group=0; mod=(8192*info->cur_group); XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd,info->cur_group); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); delete_char_in_win(info->win,aconv->keyboard->iterator); backspace_char_in_win(info->win,slen-aconv->keyboard->iterator); aconv->keyboard->iterator=0; { GList *p = g_list_first (aconv->keyboard->ks); while (p) { Skeysym *sks=(Skeysym *)p->data; send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+sks->mod); p = g_list_next (p); } } }
void xConvert_text_rus (gpointer data,WInfo *info) { int i=1; int mod=0; size_t slen; AConvert *aconv = (AConvert *)data; if((aconv==NULL)||(info==NULL)) return; slen =aconv->keyboard->gstr->len;//g_list_length (info->ks); if(slen<=0) { free_keysym_to_list(aconv); return ; } for (i = 0; i <= aconv->sxkb->ngroups; i++) { DEBUG_MSG("%s\n",aconv->sxkb->group2info[0]->name); if ((g_strcasecmp(aconv->sxkb->group2info[i]->name, "Russian") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "Russian(phonetic)") == 0) || (g_strcasecmp(aconv->sxkb->group2info[i]->name, "Russia - Winkeys") == 0)) break; } info->cur_group=i; mod=(8192*i); XkbLockGroup(aconv->keyboard->dpy, XkbUseCoreKbd,i); update_flag(aconv->sxkb->group2info[aconv->sxkb->cur_group],aconv); delete_char_in_win(info->win,aconv->keyboard->iterator); backspace_char_in_win(info->win,slen-aconv->keyboard->iterator); aconv->keyboard->iterator=0; { GList *p = g_list_first (aconv->keyboard->ks); while (p) { Skeysym *sks=(Skeysym *)p->data; send_key_to_win(info->win,XKeysymToKeycode(aconv->keyboard->dpy,sks->key),mod+sks->mod); p = g_list_next (p); } } }
void MATRIX_rotate(MATRIX *matrix, double angle) { double sina = sin(angle); double cosa = cos(angle); double m11 = cosa * matrix->m11 + sina * matrix->m21; double m12 = cosa * matrix->m12 + sina * matrix->m22; double m21 = sina * matrix->m11 + cosa * matrix->m21; double m22 = sina * matrix->m12 + cosa * matrix->m22; matrix->m11 = m11; matrix->m12 = m12; matrix->m21 = m21; matrix->m22 = m22; update_flag(matrix); }
/* PUBLIC */ void flag_handler(FILE *fout, Term t, int unknown_action) { int flag = str_to_flag_id(sn_to_str(SYMNUM(ARG(t,0)))); if (flag == -1) { if (unknown_action == KILL_UNKNOWN) { fwrite_term_nl(fout, t); fwrite_term_nl(stderr, t); fatal_error("flag not recognized"); } else if (unknown_action == WARN_UNKNOWN) { bell(stderr); fprintf(fout, "WARNING, flag not recognized: "); fwrite_term_nl(fout, t); fprintf(stderr, "WARNING, flag not recognized: "); fwrite_term_nl(stderr, t); } else if (unknown_action == NOTE_UNKNOWN) { fprintf(fout, "NOTE: flag not recognized: "); fwrite_term_nl(fout, t); } } else update_flag(fout, flag, is_term(t, "set", 1)); } /* flag_handler */
int cmd_user(sqlite3 *db,char **errmsg,vpChat temp,int sockfd)//用语判别用户信息 { int flag; int sayflag; printf("cmd = %d\n",temp->cmd); switch(temp->cmd ) { case REG: { flag = read_user(db,errmsg,temp->name); if(flag == USERIN) { return REGNO;//注册重名 } else { reg_db(db,errmsg,temp->name,temp->passwd); temp->flag = read_id(db,errmsg,temp->name); return REGOK; } break; } case LOG: { int flagpasswd; flag = read_online_ok(db,errmsg,temp->name); if(flag == ONLINEIN) { return ONLINEIN; } else { flagpasswd = read_pass(db,errmsg,temp->name,temp->passwd); if(flagpasswd == PASSWDOK) { log_db(db,errmsg,temp->name,sockfd); return PASSWDOK; } else { return PASSWDNO; } } break; } case LOGID: { int flagpasswd; read_id_name(db,errmsg,temp);//询问有无此用户 flag = read_online_ok(db,errmsg,temp->name); if(flag == ONLINEIN) { return ONLINEIN; } else { flagpasswd = read_pass(db,errmsg,temp->name,temp->passwd); if(flagpasswd == PASSWDOK) { log_db(db,errmsg,temp->name,sockfd); return PASSWDOK; } else { return PASSWDNO; } } break; } case CHAT: { int tempfd; tempfd = read_online_fd(db,errmsg,temp->toname); if(tempfd == ONLINEOUT) { return ONLINEOUT; } else { sayflag = read_online_flag(db,errmsg,temp->name); if(sayflag == 0) { return MYFLAGNO; } else { temp->flag = flag; temp->sockfd = tempfd; insert_data_db(db,errmsg,temp->time,temp); return CHATOK; } } break; } case ALL: { sayflag = read_online_flag(db,errmsg,temp->name); if(sayflag == 0) { return MYFLAGNO; } else { insert_data_db(db,errmsg,temp->time,temp); return ALLOK; } break; } case SMILE: { sayflag = read_online_flag(db,errmsg,temp->name); if(sayflag == 0) { return MYFLAGNO; } else { insert_data_db(db,errmsg,temp->time,temp); return SMILEOK; } break; } case WELCOME: { sayflag = read_online_flag(db,errmsg,temp->name); if(sayflag == 0) { return MYFLAGNO; } else { insert_data_db(db,errmsg,temp->time,temp); return WELCOMEOK; } break; } case PASSWD: { flag = update_passwd(db,errmsg,temp->name,temp->passwd); return flag; break; } case BOOT: { int tempfd; tempfd = read_online_fd(db,errmsg,temp->toname); if(tempfd == ONLINEOUT) { return ONLINEOUT; } else { temp->sockfd = tempfd; return BOOTOK; } break; } case STEP: { int tempfd; tempfd = read_online_fd(db,errmsg,temp->toname); if(tempfd == ONLINEOUT) { return ONLINEOUT; } else { flag = update_flag(db,errmsg,temp->toname,0); if(flag == 1) { temp->sockfd = tempfd; } return flag; } break; } case BAN: { int tempfd; tempfd = read_online_fd(db,errmsg,temp->toname); if(tempfd == ONLINEOUT) { return ONLINEOUT; } else { sayflag = read_online_flag(db,errmsg,temp->toname); if(sayflag == 1) { return TOFLAGOK; } else { flag = update_flag(db,errmsg,temp->toname,1); if(flag == 1) { temp->sockfd = tempfd; } return flag; } } break; } case SET: { int tempfd; tempfd = read_online_fd(db,errmsg,temp->toname); if(tempfd == ONLINEOUT) { flag = delete_user(db,errmsg,temp->toname); return flag; } else { return ONLINEIN; } break; } case SEE: { return SEEOK; break; } case DATA: { return DATAOK; break; } case SEND: { int tempfd; tempfd = read_online_fd(db,errmsg,temp->toname); if(tempfd == ONLINEOUT) { return ONLINEOUT; } else { temp->sockfd = tempfd; return SENDOK; } break; } case CHANGE: { flag = read_user(db,errmsg,temp->toname); if(flag == USERIN) { return REGNO;//注册重名 } else { flag = update_user(db,errmsg,temp->name,temp->toname);//¿¿¿¿ if(flag == 1) { sayflag = update_db_data(db,errmsg,temp->name,temp->toname);//修改密码 return sayflag; } else { return 0; } } break; } } }
int main(int argc, char *argv[]) { int i; int sensor_on = 0; int ldw = 0; int ret = 0; int initial_err = 0; int sensor60fps = 0; gpCVR_VStream_Cfg cfg; if((strcmp(SYSCONFIG_PLATFORM, "gplus.cvr_turnkey_demo0") == 0 )|| ( strcmp(SYSCONFIG_PLATFORM, "gplus.cvr_turnkey_demo2") == 0 )) { g_flip_on = 0; g_flip_off = 1; } else { g_flip_on = 1; g_flip_off = 0; } global_flip = g_flip_off; memset(&cfg, 0, sizeof(gpCVR_VStream_Cfg)); cfg.sensor_calibrate = &ar0330_cdsp_calibration; cfg.cdsp_user_preference = &cdsp_user_preference; memset(cam_working_path, 0, 256); if (strcmp(argv[1], "-dv") == 0) mode = DV_MODE; else if (strcmp(argv[1], "-dc") == 0) mode = DC_MODE; else return -1; dv_parse_command(argc, argv); dc_parse_command(argc, argv); signal(SIGUSR1,get_signal_user1); signal(SIGUSR2,get_signal_user2); signal(SIGTERM,get_signal_term); ldw = global_ldw; update_flag(&cfg.flag, CFG_LDW, ldw); sensor60fps = global_60fps; sensor_on = 0; RegisterSigint(); while(!powerOff) { //unsigned int msgId; //void* msgPara = NULL; if (mode == DV_MODE) { cfg.mode = MODE_H264; update_flag(&cfg.flag, CFG_LDW, global_ldw); cfg.width = cfg.height = cfg.fps = 0; if (global_60fps) { cfg.width = 1280; cfg.height = 720; cfg.fps = 60; } if (!sensor_on) { ret = gp_IPC_VStream_Open(&cfg); } else if (global_ldw != ldw || global_60fps != sensor60fps) { gp_IPC_VStream_Close(); ret = gp_IPC_VStream_Open(&cfg); } if (ret < 0) { initial_err = 1; powerOff = 1; } sensor_on = 1; gp_IPC_VStream_Start(); printf("Start DV Mode\n"); ret = dv_main(argc, argv); if (ret < 0) { powerOff = 1; continue; } mode = WAIT_MODE; ldw = global_ldw; sensor60fps = global_60fps; } else if (mode == DC_MODE) { cfg.mode = MODE_JPG; update_flag(&cfg.flag, CFG_LDW, 0); cfg.width = cfg.height = cfg.fps = 0; if (!sensor_on) { ret = gp_IPC_VStream_Open(&cfg); } else if (ldw || sensor60fps) { gp_IPC_VStream_Close(); ret = gp_IPC_VStream_Open(&cfg); } if (ret < 0) { initial_err = 1; powerOff = 1; continue; } ldw = 0; sensor60fps = 0; sensor_on = 1; gp_IPC_VStream_Start(); printf("Start DC Mode\n"); ret = dc_main(argc, argv); if (ret < 0) { powerOff = 1; continue; } mode = WAIT_MODE; } else if (mode == IDLE_MODE) { if (sensor_on) { printf("Sensor Stop\n"); //gp_IPC_VStream_Stop(); gp_IPC_VStream_Close(); sensor_on = 0; } mode = WAIT_MODE; } g_bQuit = 0; usleep(5000); } if (initial_err) { printf("[camcorder] Initialize Error\n"); dvr_pipe_init(); dvr_pipemsg_send(CMD_READY_KEY, 0, NULL); dvr_pipe_close(); } else { gp_IPC_VStream_Close(); } printf("[camcorder] program exit\n"); return ret; }
int main(void) //(int argc, char *argv[]) { printf("Bingo, enter 1st simulator DSP APP~!\n"); #if 0 u8 i, _i; u32 cnt, next; u32 msk, setmsk, clrmsk; u32 delta, deltamin, tnext, hi, lo; u32 *nextp; const u32 *hilop; u32 period; u32 enmask; /* enable mask */ u32 stmask; /* state mask */ static u32 next_hi_lo[MAX_PWMS][3]; #endif /* * init Obj objects of each Chn. */ ChanelObj chnObj[MAX_PWMS]; u32 i = 0; u32 currTime = 0; //u32 sartRiseTime = 0; //u32 startFallTime = 0; for (i = 0; i < MAX_PWMS; i++) { chnObj[i].chid = i + 1; chnObj[i].enmask = 0; } u32 prevTime = 0; time64 currTs64; while (1) { u32 index = 0; //step 1 : update current time. currTime = read_PIEP_COUNT(); if(prevTime > currTime) { // reverse currTs64.time_p2++; } currTs64.time_p1 = currTime; prevTime = currTime; update_flag(); //step 2: judge current if it is arrive at rising edge time for (index = 0; index < MAX_PWMS; index++) { //it is time that arriving rising edge........ if(TIME_GREATER(currTs64, chnObj[index].time_of_hi)) { chnObj[index].enmask = PWM_CMD ->enmask; chnObj[index].period_time.time_p1 = PWM_CMD ->periodhi[index][0]; // update time stamp //chnObj[index].time_of_lo.time_p2 = 0; //chnObj[index].time_of_lo.time_p1 = PWM_CMD ->periodhi[index][1]; // chnObj[index].time_of_lo = time_add(chnObj[index].time_of_lo, currTs64); TIME_ADD(chnObj[index].time_of_lo, currTs64, PWM_CMD ->periodhi[index][1]); //rising_edge_time = current + period // chnObj[index].time_of_hi = time_add(chnObj[index].period_time, currTs64); TIME_ADD(chnObj[index].time_of_hi, currTs64, PWM_CMD ->periodhi[index][0]); if (chnObj[index].enmask & (1U << index)) { // sartRiseTime = read_PIEP_COUNT(); //fall_edge_time = current + hi_duty __R30 |= (1U << index); //pull up printf("<high> chn: %d cur [%08x-%08x] r30 %x hi [%08x-%08x] lo [%08x-%08x] perid %d(high: %d) \n" ,chnObj[index].chid, currTs64.time_p2, currTs64.time_p1, __R30, chnObj[index].time_of_hi.time_p2, chnObj[index].time_of_hi.time_p1, chnObj[index].time_of_lo.time_p2, chnObj[index].time_of_lo.time_p1, time_sub(currTs64, ts[index][0]), PWM_CMD ->periodhi[index][1]); ts[index][0] = currTs64; } continue; } //it is time that arriving falling edge........ if(TIME_GREATER(currTs64, chnObj[index].time_of_lo)) { TIME_ADD(chnObj[index].time_of_lo, currTs64, PWM_CMD ->periodhi[index][0]); if (chnObj[index].enmask & (1U << index)) { __R30 &= ~(1U << index); //pull down printf("<low> chn: %d cur [%08x-%08x] r30 %x hi [%08x-%08x] lo [%08x-%08x] high-len %d \n" ,chnObj[index].chid, currTs64.time_p2, currTs64.time_p1, __R30, chnObj[index].time_of_hi.time_p2, chnObj[index].time_of_hi.time_p1, chnObj[index].time_of_lo.time_p2, chnObj[index].time_of_lo.time_p1, time_sub(currTs64, ts[index][0])); ts[index][1] = currTs64; } } } } #if 0 //static struct cxt cxt; #if 0 /* enable OCP master port */ PRUCFG_SYSCFG &= ~SYSCFG_STANDBY_INIT; PRUCFG_SYSCFG = (PRUCFG_SYSCFG & ~(SYSCFG_IDLE_MODE_M | SYSCFG_STANDBY_MODE_M)) | SYSCFG_IDLE_MODE_NO | SYSCFG_STANDBY_MODE_NO; /* our PRU wins arbitration */ PRUCFG_SPP |= SPP_PRU1_PAD_HP_EN; pwm_setup(); /* configure timer */ PIEP_GLOBAL_CFG = GLOBAL_CFG_DEFAULT_INC(1) | GLOBAL_CFG_CMP_INC(1); PIEP_CMP_STATUS = CMD_STATUS_CMP_HIT(1); /* clear the interrupt */ PIEP_CMP_CMP1 = 0x0; PIEP_CMP_CFG |= CMP_CFG_CMP_EN(1); PIEP_GLOBAL_CFG |= GLOBAL_CFG_CNT_ENABLE; #endif /* initialize */ cnt = read_PIEP_COUNT(); enmask = cfg.enmask; stmask = 0; /* starting all low */ clrmsk = 0; for (i = 0, msk = 1, nextp = &next_hi_lo[0][0], hilop = &cfg.hilo[0][0]; i < MAX_PWMS; i++, msk <<= 1, nextp += 3, hilop += 2) { if ((enmask & msk) == 0) { nextp[1] = PRU_us(100); /* default */ nextp[2] = PRU_us(100); continue; } nextp[0] = cnt; /* next */ nextp[1] = 200000; /* hi */ nextp[2] = 208000; /* lo */ PWM_CMD ->periodhi[i][0] = 408000; PWM_CMD ->periodhi[i][1] = 180000; } PWM_CMD ->enmask = 0; clrmsk = enmask; setmsk = 0; /* guaranteed to be immediate */ deltamin = 0; next = cnt + deltamin; PWM_CMD ->magic = PWM_REPLY_MAGIC; while (1) { update_flag(); if (PWM_CMD ->magic == PWM_CMD_MAGIC) { msk = PWM_CMD ->enmask; for (i = 0, nextp = &next_hi_lo[0][0]; i < MAX_PWMS; i++, nextp += 3) { //Enable if ((PWM_EN_MASK & (msk & (1U << i))) && (enmask & (msk & (1U << i))) == 0) { enmask |= (msk & (1U << i)); __R30 |= (msk & (1U << i)); // first enable if (enmask == (msk & (1U << i))) cnt = read_PIEP_COUNT(); nextp[0] = cnt; //since we start high, wait this amount deltamin = 0; next = cnt; } //Disable if ((PWM_EN_MASK & (msk & (1U << i))) && ((msk & ~(1U << i)) == 0)) { enmask &= ~(1U << i); __R30 &= ~(1U << i); } //get and set pwm_vals if (PWM_EN_MASK & (msk & (1U << i))) { if (b_true == full_period) { //nextp = &next_hi_lo[i * 3]; nextp[1] = PWM_CMD ->periodhi[i][1]; period = PWM_CMD ->periodhi[i][0]; nextp[2] = period - nextp[1]; } } PWM_CMD ->hilo_read[i][0] = nextp[0]; PWM_CMD ->hilo_read[i][1] = nextp[1]; } // guaranteed to be immediate deltamin = 0; PWM_CMD ->magic = PWM_REPLY_MAGIC; } PWM_CMD ->enmask_read = enmask; /* if nothing is enabled just skip it all */ if (enmask == 0) continue; setmsk = 0; clrmsk = (u32) -1; deltamin = PRU_ms(100); /* (1U << 31) - 1; */ next = cnt + deltamin; for (_i = 0; _i < MAX_PWMS; _i++) { if (enmask & (1U << (_i))) { // nextp = &next_hi_lo[(_i)][0]; // tnext = nextp[0]; // hi = nextp[1]; // lo = nextp[2]; // /* avoid signed arithmetic */ // while (((delta = (tnext - cnt)) & (1U << 31)) != 0) { // /* toggle the state */ // if (stmask & (1U << (_i))) { // stmask &= ~(1U << (_i)); // clrmsk &= ~(1U << (_i)); // tnext += lo; // printf("CH %d: next hi: %08x\n", _i, tnext); // flag when all motor channel finish full period ch_num_period++; if (!((ch_num_period) %= MAX_PWMS)) { full_period = b_true; printf( "----------------full period--------------\n"); } } else { // stmask |= (1U << (_i)); // setmsk |= (1U << (_i)); // tnext += hi; // full_period = b_false; //if(flag == Period_change) } // } // if (delta <= deltamin) { // deltamin = delta; // next = tnext; // } // nextp[0] = tnext; // } // } #if 0 #define SINGLE_PWM(_i) \ do { \ if (enmask & (1U << (_i))) { \ nextp = &next_hi_lo[(_i)][0]; \ tnext = nextp[0]; \ hi = nextp[1]; \ lo = nextp[2]; \ /* avoid signed arithmetic */ \ while (((delta = (tnext - cnt)) & (1U << 31)) != 0) { \ /* toggle the state */ \ if (stmask & (1U << (_i))) { \ stmask &= ~(1U << (_i)); \ clrmsk &= ~(1U << (_i)); \ tnext += lo; \ } else { \ stmask |= (1U << (_i)); \ setmsk |= (1U << (_i)); \ tnext += hi; \ } \ } \ if (delta <= deltamin) { \ deltamin = delta; \ next = tnext; \ } \ nextp[0] = tnext; \ } \ } while (0) #if MAX_PWMS > 0 && (PWM_EN_MASK & BIT(0)) SINGLE_PWM(0); #endif #if MAX_PWMS > 1 && (PWM_EN_MASK & BIT(1)) SINGLE_PWM(1); #endif #if MAX_PWMS > 2 && (PWM_EN_MASK & BIT(2)) SINGLE_PWM(2); #endif #if MAX_PWMS > 3 && (PWM_EN_MASK & BIT(3)) SINGLE_PWM(3); #endif #if MAX_PWMS > 4 && (PWM_EN_MASK & BIT(4)) SINGLE_PWM(4); #endif #if MAX_PWMS > 5 && (PWM_EN_MASK & BIT(5)) SINGLE_PWM(5); #endif #if MAX_PWMS > 6 && (PWM_EN_MASK & BIT(6)) SINGLE_PWM(6); #endif #if MAX_PWMS > 7 && (PWM_EN_MASK & BIT(7)) SINGLE_PWM(7); #endif #if MAX_PWMS > 8 && (PWM_EN_MASK & BIT(8)) SINGLE_PWM(8); #endif #if MAX_PWMS > 9 && (PWM_EN_MASK & BIT(9)) SINGLE_PWM(9); #endif #if MAX_PWMS > 10 && (PWM_EN_MASK & BIT(10)) SINGLE_PWM(10); #endif #if MAX_PWMS > 11 && (PWM_EN_MASK & BIT(11)) SINGLE_PWM(11); #endif #if MAX_PWMS > 12 && (PWM_EN_MASK & BIT(12)) SINGLE_PWM(12); #endif #endif /* results in set bits where there are changes */ __R30 = (__R30 & (clrmsk & 0xfff)) | (setmsk & 0xfff); /* loop while nothing changes */ do { cnt = read_PIEP_COUNT(); //if(PWM_CMD->magic == PWM_CMD_MAGIC){ // break; //} } while (((next - cnt) & (1U << 31)) == 0); } #endif printf("Bingo, leave 1st simulator DSP APP~!\n"); }