void am335x_pinmux_spi0(void) { writel(MODE(0) | RXACTIVE | PULLUDEN, ®s->spi0_sclk); writel(MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN, ®s->spi0_d0); writel(MODE(0) | RXACTIVE | PULLUDEN, ®s->spi0_d1); writel(MODE(0) | RXACTIVE | PULLUDEN | PULLUP_EN, ®s->spi0_cs0); }
void am335x_pinmux_i2c1(void) { // I2C_DATA writel(MODE(2) | RXACTIVE | PULLUDEN | SLEWCTRL, ®s->spi0_d1); // I2C_SCLK writel(MODE(2) | RXACTIVE | PULLUDEN | SLEWCTRL, ®s->spi0_cs0); }
void am335x_pinmux_uart2(void) { // UART2_RXD writel(MODE(1) | PULLUP_EN | RXACTIVE, ®s->spi0_sclk); // UART2_TXD writel(MODE(1) | PULLUDEN, ®s->spi0_d0); }
void am335x_pinmux_uart3(void) { // UART3_RXD writel(MODE(1) | PULLUP_EN | RXACTIVE, ®s->spi0_cs1); // UART3_TXD writel(MODE(1) | PULLUDEN, ®s->ecap0_in_pwm0_out); }
void am335x_pinmux_uart4(void) { // UART4_RXD writel(MODE(6) | PULLUP_EN | RXACTIVE, ®s->gpmc_wait0); // UART4_TXD writel(MODE(6) | PULLUDEN, ®s->gpmc_wpn); }
void am335x_pinmux_uart5(void) { // UART5_RXD writel(MODE(4) | PULLUP_EN | RXACTIVE, ®s->lcd_data9); // UART5_TXD writel(MODE(4) | PULLUDEN, ®s->lcd_data8); }
int obio_iomem_add_mapping(bus_addr_t bpa, bus_size_t size, int type, bus_space_handle_t *bshp) { u_long pa, endpa; vaddr_t va; pt_entry_t *pte; unsigned int m = 0; int io_type = type & ~OBIO_IOMEM_PCMCIA_8BIT; pa = trunc_page(bpa); endpa = round_page(bpa + size); #ifdef DIAGNOSTIC if (endpa <= pa) panic("obio_iomem_add_mapping: overflow"); #endif va = uvm_km_valloc(kernel_map, endpa - pa); if (va == 0) return (ENOMEM); *bshp = (bus_space_handle_t)(va + (bpa & PGOFSET)); #define MODE(t, s) \ ((t) & OBIO_IOMEM_PCMCIA_8BIT) ? \ _PG_PCMCIA_ ## s ## 8 : \ _PG_PCMCIA_ ## s ## 16 switch (io_type) { default: panic("unknown pcmcia space."); /* NOTREACHED */ case OBIO_IOMEM_PCMCIA_IO: m = MODE(type, IO); break; case OBIO_IOMEM_PCMCIA_MEM: m = MODE(type, MEM); break; case OBIO_IOMEM_PCMCIA_ATT: m = MODE(type, ATTR); break; } #undef MODE for (; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { pmap_kenter_pa(va, pa, PROT_READ | PROT_WRITE); pte = __pmap_kpte_lookup(va); KDASSERT(pte); *pte |= m; /* PTEA PCMCIA assistant bit */ sh_tlb_update(0, va, *pte); } return (0); }
/* Check mode of file. */ const char * checkmode(struct stat *sb, mode_t mode) { static char msg[128]; if ((sb->st_mode & ACCESSPERMS) == mode) return (NULL); xsnprintf(msg, sizeof msg, "bad permissions:" " %o%o%o, should be %o%o%o", MODE(sb->st_mode), MODE(mode)); return (msg); }
bool display_result(state *s, const TCHAR * fn, const char * sum) { // Only spend the extra time to make a Filedata object if we need to if (MODE(mode_match_pretty) or MODE(mode_match) or MODE(mode_directory)) { Filedata * f; try { f = new Filedata(fn, sum); } catch (std::bad_alloc) { fatal_error("%s: Unable to create Filedata object in engine.cpp:display_result()", __progname); } if (MODE(mode_match_pretty)) { if (match_add(s,f)) print_error_unicode(s,fn,"Unable to add hash to set of known hashes"); } else { // This block is for MODE(mode_match) or MODE(mode_directory) match_compare(s,f); if (MODE(mode_directory)) if (match_add(s,f)) print_error_unicode(s, fn, "Unable to add hash to set of known hashes"); } } else { // No special options selected. Display the hash for this file if (s->first_file_processed) { print_status("%s", OUTPUT_FILE_HEADER); s->first_file_processed = false; } printf ("%s,\"", sum); display_filename(stdout,fn,TRUE); print_status("\""); } return false; }
void rounded_rectangles (cairo_perf_t *perf, cairo_t *cr, int width, int height) { int i; srand (8478232); for (i = 0; i < RECTANGLE_COUNT; i++) { rects[i].x = rand () % width; rects[i].y = rand () % height; rects[i].width = (rand () % (width / 10)) + 1; rects[i].height = (rand () % (height / 10)) + 1; } MODE (perf, "one-rounded-rectangle", do_rectangle); MODE (perf, "rounded-rectangles", do_rectangles); }
int test_config(void) { printf("\n\tTouch in the mouse\n\n"); unsigned long data, res; unsigned char a[3]; mouse_subscribe(); mouse_write(MOUSE_STATUS); mouse_read(&data); while (1) { mouse_read(&data); if ((BIT(7) & data) && (BIT(3) & res)) break; } a[0] = data; while (1) { mouse_read(&data); if (data <= 3) break; } a[1] = data; tickdelay(micros_to_ticks(DELAY_US)); if (mouse_read(&data) != 0) return -1; a[2] = data; printf("\n\tCONFIGURATION\n"); printf( "\tMode: %s\n\tEnable: %d\n\tScaling: %s\n\tLB: %d\n\tMB: %d\n\tRB: %d\n\tResolution: %d count/mm\n\tSample Rate: %d\n", MODE(a[0]) ? "Remote" : "Stream", ENABLE(a[0]), SCALING(a[0]) ? "1:1" : "2:1", LEFT(a[0]), MIDDLE(a[0]), RIGHT(a[0]), RESOLUTION(a[1]), RATE(a[2])); mouse_unsubscribe(); printf("\n\tpress ANY KEY to continue\n"); mouse_read(&res); /* clear out buffer */ }
void DSPC::handleMessage(IBusMessage *m) { if(m->data[0]==0x01) { if(reset) { ibus.sendMessage(DEVICE_DSPC,DEVICE_LOC,DEVICE_STATUS_READY_AFTER_RESET,sizeof(DEVICE_STATUS_READY_AFTER_RESET)); reset=false; } else { ibus.sendMessage(DEVICE_DSPC,DEVICE_LOC,DEVICE_STATUS_READY,sizeof(DEVICE_STATUS_READY)); } return; } if(m->data[0]==0x35) { needMemoryInfo=false; // update from DSP mode = MODE(m->data[1] - 1); reverb = m->data[2] & 0x0F; if(m->data[2]&0x10) reverb*=-1; roomsize = m->data[3] & 0x0F; if(m->data[3]&0x10) roomsize*=-1; for(int f = 0; f < 7; f++) { boost[f] = m->data[4+f] & 0x0F; if(m->data[4+f] & 0x10) boost[f]*=-1; } } }
void print_ntp_control_message(const ntp_control_message *p){ int i=0, numpeers=0; const ntp_assoc_status_pair *peer=NULL; printf("control packet contents:\n"); printf("\tflags: 0x%.2x , 0x%.2x\n", p->flags, p->op); printf("\t li=%d (0x%.2x)\n", LI(p->flags), p->flags&LI_MASK); printf("\t vn=%d (0x%.2x)\n", VN(p->flags), p->flags&VN_MASK); printf("\t mode=%d (0x%.2x)\n", MODE(p->flags), p->flags&MODE_MASK); printf("\t response=%d (0x%.2x)\n", (p->op&REM_RESP)>0, p->op&REM_RESP); printf("\t more=%d (0x%.2x)\n", (p->op&REM_MORE)>0, p->op&REM_MORE); printf("\t error=%d (0x%.2x)\n", (p->op&REM_ERROR)>0, p->op&REM_ERROR); printf("\t op=%d (0x%.2x)\n", p->op&OP_MASK, p->op&OP_MASK); printf("\tsequence: %d (0x%.2x)\n", ntohs(p->seq), ntohs(p->seq)); printf("\tstatus: %d (0x%.2x)\n", ntohs(p->status), ntohs(p->status)); printf("\tassoc: %d (0x%.2x)\n", ntohs(p->assoc), ntohs(p->assoc)); printf("\toffset: %d (0x%.2x)\n", ntohs(p->offset), ntohs(p->offset)); printf("\tcount: %d (0x%.2x)\n", ntohs(p->count), ntohs(p->count)); numpeers=ntohs(p->count)/(sizeof(ntp_assoc_status_pair)); if(p->op&REM_RESP && p->op&OP_READSTAT){ peer=(ntp_assoc_status_pair*)p->data; for(i=0;i<numpeers;i++){ printf("\tpeer id %.2x status %.2x", ntohs(peer[i].assoc), ntohs(peer[i].status)); if (PEER_SEL(peer[i].status) >= PEER_INCLUDED){ if(PEER_SEL(peer[i].status) >= PEER_SYNCSOURCE){ printf(" <-- current sync source"); } else { printf(" <-- current sync candidate"); } } printf("\n"); } } }
unsigned SOP_PrimGroupCentroid::disableParms() { fpreal t = CHgetEvalTime(); unsigned changed; int mode; OP_Node *bind_input; // Partitioning mode. mode = MODE(t); // Try to get the 2nd input. bind_input = getInput(1); // Only use the 'group' parm when doing a group operation. changed = enableParm("group", mode == 0 && bind_input == NULL); // Enable the 'store' parm when there is no 2nd input. changed += enableParm("store", bind_input == NULL); // Enable thavior' parm when there is a 2nd input. changed += enableParm("behavior", bind_input != NULL); changed += enableParm("attributes", bind_input == NULL); changed += enableParm("bind_attributes", bind_input != NULL); return changed; }
I18N_PLAY_FUNCTION(en, playNumber, getvalue_t number, uint8_t unit, uint8_t att) { if (number < 0) { PUSH_NUMBER_PROMPT(EN_PROMPT_MINUS); number = -number; } if (unit) { unit--; convertUnit(number, unit); if (IS_IMPERIAL_ENABLE()) { if (unit == UNIT_DIST) { unit = UNIT_FEET; } if (unit == UNIT_SPEED) { unit = UNIT_KTS; } } unit++; } int8_t mode = MODE(att); if (mode > 0) { // we assume that we are PREC1 div_t qr = div(number, 10); if (qr.rem) { PLAY_NUMBER(qr.quot, 0, 0); PUSH_NUMBER_PROMPT(EN_PROMPT_POINT_BASE + qr.rem); number = -1; } else { number = qr.quot; } } int16_t tmp = number; if (number >= 1000) { PLAY_NUMBER(number / 1000, 0, 0); PUSH_NUMBER_PROMPT(EN_PROMPT_THOUSAND); number %= 1000; if (number == 0) number = -1; } if (number >= 100) { PUSH_NUMBER_PROMPT(EN_PROMPT_HUNDRED + (number/100)-1); number %= 100; if (number == 0) number = -1; } if (number >= 0) { PUSH_NUMBER_PROMPT(EN_PROMPT_ZERO + number); } if (unit) { EN_PUSH_UNIT_PROMPT(tmp, EN_PROMPT_UNITS_BASE + unit*2); } }
static void mdlOutputs(SimStruct *S, int_T tid) { double sp_original; double meas_scaled; double manip_original_in; double xi_in; int mode; double K; double Ti; double h; double LO_y; double HI_y; double LO_u; double HI_u; int action; int P_only; double rel_lo; double rel_hi; double hys; double hi_flag_in; double *manip_original; double *xi; double *hi_flag; #ifdef DEBUG debug("mdlOutputs entered.\n"); #endif sp_original = SETPOINT(S); meas_scaled = INPUT(S); manip_original_in = MV(S); xi_in = XI(S); mode = MODE(S); K = GAIN(S); Ti = RESET(S); h = SAMPLING(S); LO_y = LOWMEAS(S); HI_y = HIGHMEAS(S); LO_u = LOWMV(S); HI_u = HIGHMV(S); action = PGAIN(S); P_only = PONLY(S); rel_lo = RELLO(S); rel_hi = RELHI(S); hys = HYS(S); hi_flag_in = HIFLAG(S); manip_original = &OUTPUT(S); xi = &XO(S); hi_flag = &FLAG(S); controller(manip_original, xi, hi_flag, sp_original, meas_scaled, manip_original_in, xi_in, mode, K, Ti, h, LO_y, HI_y, LO_u, HI_u, action, P_only, rel_lo, rel_hi, hys, hi_flag_in); #ifdef DEBUG debug("mdlOutputs left.\n"); #endif } /* mdlOutputs */
void rectangles (cairo_perf_t *perf, cairo_t *cr, int width, int height) { int i; if (! cairo_perf_can_run (perf, "rectangles", NULL)) return; srand (8478232); for (i = 0; i < RECTANGLE_COUNT; i++) { rects[i].x = rand () % width; rects[i].y = rand () % height; rects[i].width = (rand () % (width / 10)) + 1; rects[i].height = (rand () % (height / 10)) + 1; } MODE (perf, "one-rectangle", do_rectangle); MODE (perf, "rectangles", do_rectangles); MODE (perf, "rectangles-once", do_rectangles_once); }
/// Open a file of known hashes and determine if it's valid /// /// @param s State variable /// @param fn filename to open /// /// @return Returns false success, true on error bool sig_file_open(state *s, const char * fn) { if (NULL == s or NULL == fn) return true; s->known_handle = fopen(fn,"rb"); if (NULL == s->known_handle) { if ( ! (MODE(mode_silent)) ) perror(fn); return true; } // The first line of the file should contain a valid ssdeep header. char buffer[MAX_STR_LEN]; if (NULL == fgets(buffer,MAX_STR_LEN,s->known_handle)) { if ( ! (MODE(mode_silent)) ) perror(fn); fclose(s->known_handle); return true; } chop_line(buffer); if (strncmp(buffer,SSDEEPV1_0_HEADER,MAX_STR_LEN) and strncmp(buffer,SSDEEPV1_1_HEADER,MAX_STR_LEN)) { if ( ! (MODE(mode_silent)) ) print_error(s,"%s: Invalid file header.", fn); fclose(s->known_handle); return true; } // We've now read the first line s->line_number = 1; s->known_fn = strdup(fn); return false; }
int fix_gmode(sccs *s, int gflags) { ser_t d; /* * Do not fix mode of symlink target, the file may not be * under BK control. */ if (S_ISLNK(s->mode)) return (0); if ((gflags&GET_EDIT) && WRITABLE(s)) return (0); if (!(gflags&GET_EDIT) && !WRITABLE(s)) return (0); d = sccs_top(s); if (MODE(s, d)) s->mode = MODE(s, d); unless (gflags&GET_EDIT) { s->mode &= ~0222; /* turn off write mode */ } if (chmod(s->gfile, s->mode)) return (1); return (0); }
bool SansgridRadio::timeout(void) { bool timeout_flag = false; if (!on_network || MODE(ROUTER)) return timeout_flag; timeout_counter++; if (timeout_counter == 0) { timeout_flag = true; SpiData->control = SG_SERIAL_CTRL_VALID_DATA; memcpy(ip, router_ip, IP_LENGTH); memset(router_ip, 0, IP_LENGTH); SpiData->payload[0] = SG_CHIRP_NETWORK_DISCONNECTS_SENSOR; on_network = false; } return timeout_flag; }
OP_ERROR SOP_PrimGroupCentroid::cookMySop(OP_Context &context) { fpreal now; int method, mode; now = context.getTime(); if (lockInputs(context) >= UT_ERROR_ABORT) return error(); // The partitioning mode. mode = MODE(now); // Find out which calculation method we are attempting. method = METHOD(now); // Binding geometry. if (nConnectedInputs() == 2) { // Duplicate the source. duplicateSource(0, context); // Bind to the centroids. If the function returns 1, unlock // the inputs and return. if (bindToCentroids(now, mode, method)) { unlockInputs(); return error(); } } // Creating centroids. else { // Clear out any previous data. gdp->clearAndDestroy(); // Build the centroids. If the function returns 1, unlock // the inputs and return. if (buildCentroids(now, mode, method)) { unlockInputs(); return error(); } } unlockInputs(); return error(); }
void am335x_pinmux_mmc0(int cd, int sk_evm) { writel(MODE(0) | RXACTIVE | PULLUP_EN, ®s->mmc0_dat0); writel(MODE(0) | RXACTIVE | PULLUP_EN, ®s->mmc0_dat1); writel(MODE(0) | RXACTIVE | PULLUP_EN, ®s->mmc0_dat2); writel(MODE(0) | RXACTIVE | PULLUP_EN, ®s->mmc0_dat3); writel(MODE(0) | RXACTIVE | PULLUP_EN, ®s->mmc0_clk); writel(MODE(0) | RXACTIVE | PULLUP_EN, ®s->mmc0_cmd); if (!sk_evm) { // MMC0_WP writel(MODE(4) | RXACTIVE, ®s->mcasp0_aclkr); } if (cd) { // MMC0_CD writel(MODE(5) | RXACTIVE | PULLUP_EN, ®s->spi0_cs1); } }
bool match_compare(state *s, Filedata * f) { if (NULL == s) fatal_error("%s: Null state passed into match_compare", __progname); bool status = false; size_t fn_len = _tcslen(f->get_filename()); std::vector<Filedata* >::const_iterator it; for (it = s->all_files.begin() ; it != s->all_files.end() ; ++it) { // When in pretty mode, we still want to avoid printing // A matches A (100). if (s->mode & mode_match_pretty) { if (!(_tcsncmp(f->get_filename(), (*it)->get_filename(), std::max(fn_len,_tcslen((*it)->get_filename())))) and (f->get_signature() == (*it)->get_signature())) { // Unless these results from different matching files (such as // what happens in sigcompare mode). That being said, we have to // be careful to avoid NULL values such as when working in // normal pretty print mode. if (not(f->has_match_file()) or f->get_match_file() == (*it)->get_match_file()) continue; } } int score = fuzzy_compare(f->get_signature().c_str(), (*it)->get_signature().c_str()); if (-1 == score) print_error(s, "%s: Bad hashes in comparison", __progname); else { if (score > s->threshold or MODE(mode_display_all)) { handle_match(s,f,(*it),score); status = true; } } } return status; }
void am335x_pinmux_mmc1(void) { // MMC1_DAT0 writel(MODE(1) | RXACTIVE | PULLUP_EN, ®s->gpmc_ad0); // MMC1_DAT1 writel(MODE(1) | RXACTIVE | PULLUP_EN, ®s->gpmc_ad1); // MMC1_DAT2 writel(MODE(1) | RXACTIVE | PULLUP_EN, ®s->gpmc_ad2); // MMC1_DAT3 writel(MODE(1) | RXACTIVE | PULLUP_EN, ®s->gpmc_ad3); // MMC1_CLK writel(MODE(2) | RXACTIVE | PULLUP_EN, ®s->gpmc_csn1); // MMC1_CMD writel(MODE(2) | RXACTIVE | PULLUP_EN, ®s->gpmc_csn2); // MMC1_WP writel(MODE(7) | RXACTIVE | PULLUP_EN, ®s->gpmc_csn0); // MMC1_CD writel(MODE(7) | RXACTIVE | PULLUP_EN, ®s->gpmc_advn_ale); }
int SansgridRadio::read() { int i = 0; //while(Radio->available() > 0 && i < MAX_XB_PYLD) { while(Radio->available() && i < MAX_XB_PYLD) { delay(2); incoming_packet[i] = Radio->read(); i++; } if (MODE(SENSOR)) { uint8_t brdcst[XB_SN_LN]; memset(brdcst,0x0,XB_SN_LN); if ((memcmp(&incoming_packet[1],xbsn,XB_SN_LN) != 0) && (memcmp(&incoming_packet[1],brdcst,XB_SN_LN) != 0)) { return 0; } } return i; }
int test_config(void) { unsigned long byte; subscribe_mouse(); mouse_write_byte(DISABLE_DATA_PACKETS); mouse_write_byte(STATUS_REQUEST); byte = mouse_read(); if(byte == -1) return 1; printf("byte 1: 0x%X\n", byte); printf("Scaling: "); if(!SCALING(byte)) printf("1:1 "); else printf("2:1 "); printf("Data Reporting: "); if(!DATA_REPORTING(byte)) printf("disable "); else printf("enable "); printf("Mode: "); if(!MODE(byte)) printf("remote mode\n\n"); else printf("stream mode\n\n"); if(LB(byte)) printf("LB: pressed "); else printf("LB: not pressed "); if(RB(byte)) printf("RB: pressed "); else printf("RB: not pressed "); if(MB(byte)) printf("MB: pressed "); else printf("MB: not pressed "); byte = mouse_read(); if(byte == -1) return 1; printf("\n byte 2: 0x%X\n", byte); printf("Resolution: %d\n\n", byte); byte = mouse_read(); if(byte == -1) return 1; printf("byte 3: 0x%X\n", byte); printf("Sample Rate: %d\n\n", byte); }
bool find_matches_in_known(state *s) { if (NULL == s) return true; // Walk the vector which contains all of the known files std::vector<Filedata *>::const_iterator it; for (it = s->all_files.begin() ; it != s->all_files.end() ; ++it) { bool status = match_compare(s,*it); // In pretty mode and sigcompare mode we need to display a blank // line after each file. In clustering mode we don't display anything // right now. if (status and not(MODE(mode_cluster))) print_status(""); } return false; }
int gpio_init(gpio_t pin, gpio_mode_t mode) { const uint8_t port_num = _port_num(pin); const uint32_t port_addr = _port_base[port_num]; const uint8_t pin_num = _pin_num(pin); const uint32_t sysctl_port_base = _sysctl_port_base[port_num]; const unsigned long pin_bit = 1ul << pin_num; DEBUG("Init GPIO: port %c, %d\n", 'A' + port_num, pin_num); DEBUG("Sysctl %" PRIx32 "\n", sysctl_port_base); ROM_SysCtlPeripheralEnable(sysctl_port_base); HWREG(port_addr+GPIO_LOCK_R_OFF) = GPIO_LOCK_KEY; HWREG(port_addr+GPIO_CR_R_OFF) |= pin_bit; HWREG(port_addr+GPIO_DEN_R_OFF) |= pin_bit; HWREG(port_addr+GPIO_LOCK_R_OFF) = 0; ROM_GPIOPadConfigSet(port_addr, pin_bit, GPIO_STRENGTH_2MA, TYPE(mode)); ROM_GPIODirModeSet(port_addr, pin_bit, MODE(mode)); return 0; }
void multidrawindirect_app::onKey(int key, int action) { if (action) { switch (key) { case 'P': paused = !paused; break; case 'V': vsync = !vsync; setVsync(vsync); break; case 'D': mode = MODE(mode + 1); if (mode > MODE_MAX) mode = MODE_FIRST; break; case 'R': load_shaders(); break; } } }
/* print out a ntp packet in human readable/debuggable format */ void print_ntp_message(const ntp_message *p){ struct timeval ref, orig, rx, tx; NTP64toTV(p->refts,ref); NTP64toTV(p->origts,orig); NTP64toTV(p->rxts,rx); NTP64toTV(p->txts,tx); printf("packet contents:\n"); printf("\tflags: 0x%.2x\n", p->flags); printf("\t li=%d (0x%.2x)\n", LI(p->flags), p->flags&LI_MASK); printf("\t vn=%d (0x%.2x)\n", VN(p->flags), p->flags&VN_MASK); printf("\t mode=%d (0x%.2x)\n", MODE(p->flags), p->flags&MODE_MASK); printf("\tstratum = %d\n", p->stratum); printf("\tpoll = %g\n", pow(2, p->poll)); printf("\tprecision = %g\n", pow(2, p->precision)); printf("\trtdelay = %-.16g\n", NTP32asDOUBLE(p->rtdelay)); printf("\trtdisp = %-.16g\n", NTP32asDOUBLE(p->rtdisp)); printf("\trefid = %x\n", p->refid); printf("\trefts = %-.16g\n", NTP64asDOUBLE(p->refts)); printf("\torigts = %-.16g\n", NTP64asDOUBLE(p->origts)); printf("\trxts = %-.16g\n", NTP64asDOUBLE(p->rxts)); printf("\ttxts = %-.16g\n", NTP64asDOUBLE(p->txts)); }