//------------------------------------------------------------- // Name: RestoreDeviceObjects() // Desc: 화면크기가 변했을때 호출됨 // 확보한 메모리는 InvalidateDeviceObjects()에서 해제 //------------------------------------------------------------- HRESULT CMyD3DApplication::RestoreDeviceObjects() { // 정점과 색정보 CUSTOMVERTEX vertices[] = { // x, y, z, {-0.5f, +0.5f, 0}, {+0.5f, +0.5f, 0}, {-0.5f, -0.5f, 0}, {+0.5f, -0.5f, 0}, }; // 정점버퍼 생성 if( FAILED( m_pd3dDevice->CreateVertexBuffer( 4*sizeof(CUSTOMVERTEX), // 정점버퍼 크기 0, D3DFVF_CUSTOMVERTEX, // 사용법, 정점포맷 D3DPOOL_DEFAULT, // 메모리 클래스 &m_pVB, NULL ))) // 정점버퍼 리소스 return E_FAIL; // 정점버퍼에 정보 저장 VOID* pVertices; if(FAILED( m_pVB->Lock(0, sizeof(vertices), (void**)&pVertices, 0))) return E_FAIL; memcpy( pVertices, vertices, sizeof(vertices) ); m_pVB->Unlock(); // 단축매크로 #define RS m_pd3dDevice->SetRenderState #define TSS m_pd3dDevice->SetTextureStageState #define SAMP m_pd3dDevice->SetSamplerState // 렌더링 상태설정 RS( D3DRS_DITHERENABLE, FALSE ); RS( D3DRS_SPECULARENABLE, FALSE ); RS( D3DRS_ZENABLE, TRUE ); RS( D3DRS_AMBIENT, 0x000F0F0F ); TSS( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); TSS( 0, D3DTSS_COLORARG1, D3DTA_DIFFUSE ); // 폰트 m_pFont->RestoreDeviceObjects(); // 뷰행렬 설정 D3DXVECTOR3 vEye = D3DXVECTOR3( 0.0f, 0.0f, 1.0f ); D3DXVECTOR3 vAt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); D3DXMatrixLookAtRH( &m_matView, &vEye, &vAt, &vUp ); // 투영행렬 설정 FLOAT fAspectRatio = (FLOAT)m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height; D3DXMatrixPerspectiveFovRH( &m_matProj, D3DXToRadian(60.0f), fAspectRatio, 0.1f, 100.0f ); return S_OK; }
bool is_immediate_pair(inst_t* instp) { // find out if instp points to lis followed by ori/addi/load/store inst_t i1 = instp[0]; if (!is_lis(i1)) return false; fint reg = RT(i1); inst_t i2 = instp[1]; return is_ori(i2) && RA(i2) == reg && RS(i2) == reg || is_addi(i2) && RT(i2) == reg && RS(i2) == reg || is_load_store_immediate(i2) && RA(i2) == reg; }
static void data(unsigned char data) { RS(1); udelay(40); LCD(data >> 4); lcd_strobe(); LCD(data); lcd_strobe(); udelay(10); RS(0); udelay(10); }
//------------------------------------------------------------- // Name: RestoreDeviceObjects() // Desc: 화면크기가 변했을때 호출됨 // 확보한 메모리는 InvalidateDeviceObjects()에서 해제 //------------------------------------------------------------- HRESULT CMyD3DApplication::RestoreDeviceObjects() { // 메시 m_pMesh ->RestoreDeviceObjects( m_pd3dDevice ); m_pMeshBg->RestoreDeviceObjects( m_pd3dDevice ); // 셰이더 m_pEffect->OnResetDevice(); // 재질설정 D3DMATERIAL9 mtrl; D3DUtil_InitMaterial( mtrl, 1.0f, 0.0f, 0.0f ); m_pd3dDevice->SetMaterial( &mtrl ); // 렌더링 상태설정 RS( D3DRS_DITHERENABLE, FALSE ); RS( D3DRS_SPECULARENABLE, FALSE ); RS( D3DRS_ZENABLE, TRUE ); RS( D3DRS_AMBIENT, 0x000F0F0F ); RS( D3DRS_LIGHTING, TRUE ); TSS( 0, D3DTSS_COLOROP, D3DTOP_MODULATE ); TSS( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); TSS( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); TSS( 0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); TSS( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); SAMP( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); SAMP( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); SAMP( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP ); SAMP( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP ); // 월드행렬 D3DXMATRIX matIdentity; D3DXMatrixIdentity( &m_mWorld ); // 뷰행렬 D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 0.0f, -5.0f ); D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); D3DXMatrixLookAtLH( &m_mView, &vFromPt, &vLookatPt, &vUpVec ); // 투영행렬 FLOAT fAspect = ((FLOAT)m_d3dsdBackBuffer.Width) / m_d3dsdBackBuffer.Height; D3DXMatrixPerspectiveFovLH( &m_mProj, D3DX_PI/4, fAspect, 1.0f, 100.0f ); // 폰트 m_pFont->RestoreDeviceObjects(); return S_OK; }
//------------------------------------------------------------- // Name: RestoreDeviceObjects() // Desc: 화면크기가 변했을때 호출됨 // 확보한 메모리는 InvalidateDeviceObjects()에서 해제 //------------------------------------------------------------- HRESULT CMyD3DApplication::RestoreDeviceObjects() { // 이펙트 if(m_pEffect) m_pEffect->OnResetDevice(); // 메시 m_pMeshBg->RestoreDeviceObjects( m_pd3dDevice ); //--------------------------------------------------------- // FVF로 처리하지 않은 정점선언은 직접 처리 //--------------------------------------------------------- if( m_pMesh && m_pMesh->GetSysMemMesh() ){ LPD3DXMESH pMesh; m_pMesh->GetSysMemMesh()->CloneMesh( m_pMesh->GetSysMemMesh()->GetOptions(), decl, m_pd3dDevice, &pMesh ); D3DXComputeNormals( pMesh, NULL ); D3DXComputeTangent( pMesh, 0, 0, 0, TRUE, NULL ); SAFE_RELEASE(m_pMesh->m_pLocalMesh); m_pMesh->m_pLocalMesh = pMesh; } // 렌더링 상태설정 RS( D3DRS_ZENABLE, TRUE ); RS( D3DRS_LIGHTING, FALSE ); SAMP( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); SAMP( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); SAMP( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP ); SAMP( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP ); // 뷰행렬 D3DXVECTOR3 vFromPt = D3DXVECTOR3( 0.0f, 0.0f, -5.0f ); D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f ); D3DXVECTOR3 vUpVec = D3DXVECTOR3( 0.0f, 1.0f, 0.0f ); D3DXMatrixLookAtLH( &m_mView, &vFromPt, &vLookatPt, &vUpVec ); // 투영행렬 FLOAT fAspect = ((FLOAT)m_d3dsdBackBuffer.Width) / m_d3dsdBackBuffer.Height; D3DXMatrixPerspectiveFovLH( &m_mProj, D3DX_PI/4, fAspect, 1.0f, 100.0f ); // 폰트 m_pFont->RestoreDeviceObjects(); return S_OK; }
void handleVector(std::vector < libmaus2::dazzler::align::Overlap > & VOVL, libmaus2::dazzler::align::AlignmentWriter & AW) { uint64_t maxaepos = 0; for ( uint64_t i = 0; i < VOVL.size(); ++i ) maxaepos = std::max(maxaepos,static_cast<uint64_t>(VOVL[i].path.aepos)); libmaus2::util::SimpleQueue< libmaus2::geometry::RangeSet<ReadInterval>::search_q_element > SQ; libmaus2::geometry::RangeSet<ReadInterval> RS(maxaepos); for ( uint64_t i = 0; i < VOVL.size(); ++i ) { uint64_t const abpos = VOVL[i].path.abpos; uint64_t const aepos = VOVL[i].path.aepos; uint64_t const nf = RS.search(ReadInterval(abpos,aepos,i),SQ); bool const primary = (! nf); if ( primary ) { VOVL[i].setPrimary(); //std::cerr << "primary " << VOVL[i] << std::endl; RS.insert(ReadInterval(abpos,aepos,i)); } else { //std::cerr << "secondary " << VOVL[i] << std::endl; } } for ( uint64_t i = 0; i < VOVL.size(); ++i ) AW.put(VOVL[i]); VOVL.resize(0); }
void SetServerText() { char localbuf[80]; wsprintf(localbuf, RS(IDS_BBSERV), nConnections); SetWindowText(hMainWnd, localbuf); }
std::vector<typename TransformationLayer<Dtype>::Affine2D> TransformationLayer<Dtype>::generate(int N, int W, int H, int Wo, int Ho) { std::vector<Affine2D> r; for (int i = 0; i < N; i++) { if (synchronized_ && i) { r.push_back(r.back()); } else { Dtype rot = 0, scale = 1, sx = 0, sy = 0; if (rotate_) caffe_rng_uniform<Dtype>(1, -M_PI, M_PI, &rot); Dtype sin_rot = sin(rot); Dtype cos_rot = cos(rot); Dtype rot_w = Wo*fabs(cos_rot) + Ho*fabs(sin_rot); Dtype rot_h = Wo*fabs(sin_rot) + Ho*fabs(cos_rot); Dtype max_scale = std::min(max_scale_, std::min(H / rot_h, W / rot_w)); Dtype min_scale = std::min(min_scale_, max_scale); caffe_rng_uniform<Dtype>(1, min_scale, max_scale, &scale); Dtype scl_w = std::min(rot_w * scale, Dtype(W)); caffe_rng_uniform<Dtype>(1, -(W-scl_w)/2, (W-scl_w)/2, &sx); Dtype scl_h = std::min(rot_h * scale, Dtype(H)); caffe_rng_uniform<Dtype>(1, -(H-scl_h)/2, (H-scl_h)/2, &sy); Affine2D T0(1, 0, 0, 1, -0.5*Wo, -0.5*Ho); Affine2D RS(scale * cos_rot, -scale * sin_rot, scale * sin_rot, scale * cos_rot, 0, 0); if (mirror_ && caffe_rng_rand()&1) { RS.a00_ = -RS.a00_; RS.a10_ = -RS.a10_; } Affine2D T1(1, 0, 0, 1, 0.5*W + sx, 0.5*H + sy); r.push_back(T1*RS*T0); } } return r; }
int main(int argc, const char *argv[]) { enablePool(RPool); ComplexTest(); // [ ] , [ [ [ ] ] ], [ [ ] [] [ ] ] const RString *source = RS(" ++++++++++ [ >+++++++>++++++++++>+++>+<<<<- ] >++\n" " .>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.\n" " ------.--------.>+.>."); RVirtualFunction *function = c(RVirtualFunction)(nil); function->name = RSC("Hello"); function->masterRDataObject = makeRDataAllocated(5); function->masterRDataObject->data[0] = r_addition; function->masterRDataObject->data[1] = 0x01; function->masterRDataObject->data[2] = r_addition; function->masterRDataObject->data[3] = 0x23; function->masterRDataObject->data[4] = r_end; // brainfuck hard(with [, ]) hello world on RVM // RVirtualFunction *function = $(RVC, m(createFunctionFromBrainFuckSourceCode, RVirtualCompiler)), source ); p(RVirtualFunction)(function); executeRay(function); deleter(function, RVirtualFunction); deleter(RVM, RVirtualMachine); deleter(RVC, RVirtualCompiler); endRay(); }
static PetscErrorCode KSPFGMRESBuildSoln(PetscScalar *nrs,Vec vguess,Vec vdest,KSP ksp,PetscInt it) { PetscScalar tt; PetscErrorCode ierr; PetscInt ii,k,j; KSP_FGMRES *fgmres = (KSP_FGMRES*)(ksp->data); PetscFunctionBegin; /* Solve for solution vector that minimizes the residual */ /* If it is < 0, no fgmres steps have been performed */ if (it < 0) { ierr = VecCopy(vguess,vdest);CHKERRQ(ierr); /* VecCopy() is smart, exists immediately if vguess == vdest */ PetscFunctionReturn(0); } /* so fgmres steps HAVE been performed */ /* solve the upper triangular system - RS is the right side and HH is the upper triangular matrix - put soln in nrs */ if (*HH(it,it) != 0.0) { nrs[it] = *RS(it) / *HH(it,it); } else { nrs[it] = 0.0; } for (ii=1; ii<=it; ii++) { k = it - ii; tt = *RS(k); for (j=k+1; j<=it; j++) tt = tt - *HH(k,j) * nrs[j]; nrs[k] = tt / *HH(k,k); } /* Accumulate the correction to the soln of the preconditioned prob. in VEC_TEMP - note that we use the preconditioned vectors */ ierr = VecSet(VEC_TEMP,0.0);CHKERRQ(ierr); /* set VEC_TEMP components to 0 */ ierr = VecMAXPY(VEC_TEMP,it+1,nrs,&PREVEC(0));CHKERRQ(ierr); /* put updated solution into vdest.*/ if (vdest != vguess) { ierr = VecCopy(VEC_TEMP,vdest);CHKERRQ(ierr); ierr = VecAXPY(vdest,1.0,vguess);CHKERRQ(ierr); } else { /* replace guess with solution */ ierr = VecAXPY(vdest,1.0,VEC_TEMP);CHKERRQ(ierr); } PetscFunctionReturn(0); }
rdfheaderrec *rdfgetheaderrec(rdffile *f) { static rdfheaderrec r; int i; if (!f->header_loc) { rdf_errno = 5; return NULL; } if (f->header_fp >= f->header_len) return 0; RI8(r.type); switch(r.type) { case 1: /* Relocation record */ RI8(r.r.segment); RI32(r.r.offset); RI8(r.r.length); RI16(r.r.refseg); break; case 2: /* Imported symbol record */ RI16(r.i.segment); RS(r.i.label,32); break; case 3: /* Exported symbol record */ RI8(r.e.segment); RI32(r.e.offset); RS(r.e.label,32); break; case 4: /* DLL record */ RS(r.d.libname,127); break; case 5: /* BSS reservation record */ RI32(r.b.amount); break; default: rdf_errno = 2; /* invalid file */ return NULL; } return &r; }
void store_inferior_registers (int regno) { struct reg inferior_registers; #ifdef PT_SETFPREGS struct fpreg inferior_fp_registers; #endif int i; for (i = 0; i < 32; i++) RS (i, inferior_registers.fixreg[i]); RS (PPC_LR_REGNUM, inferior_registers.lr); RS (PPC_CR_REGNUM, inferior_registers.cr); RS (PPC_XER_REGNUM, inferior_registers.xer); RS (PPC_CTR_REGNUM, inferior_registers.ctr); RS (PC_REGNUM, inferior_registers.pc); ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & inferior_registers, 0); #ifdef PT_SETFPREGS for (i = 0; i < 32; i++) RS (FP0_REGNUM + i, inferior_fp_registers.r_regs[i]); ptrace (PT_SETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0); #endif }
static void cmd(unsigned char command) { RS(0); udelay(40); LCD(command >> 4); lcd_strobe(); LCD(command); lcd_strobe(); }
void SetClientText() { char localbuf[80]; wsprintf(localbuf, RS(bConnected ? IDS_BBON : IDS_BBOFF), (LPSTR)szServerName); SetWindowText(hMainWnd, localbuf); }
void LCD1602::Locate(int col, int row) { taskENTER_CRITICAL(); RS(false); DB(0x80 | (row << 6) | col); LCD_DELAY_WRITE; taskEXIT_CRITICAL(); }
//------------------------------------------------------------- // Name: RestoreDeviceObjects() // Desc: 화면크기가 변했을때 호출됨 // 확보한 메모리는 InvalidateDeviceObjects()에서 해제 //------------------------------------------------------------- HRESULT CMyD3DApplication::RestoreDeviceObjects() { // 렌더링 상태설정 RS( D3DRS_DITHERENABLE, FALSE ); RS( D3DRS_SPECULARENABLE, FALSE ); RS( D3DRS_ZENABLE, TRUE ); SAMP( 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); SAMP( 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); SAMP( 0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP ); SAMP( 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP ); // 폰트 m_pFont->RestoreDeviceObjects(); m_pEffect->OnResetDevice(); return S_OK; }
void LCD1602::InitFont() { char arrow[] = {0x8,0xc,0xe,0xf,0xe,0xc,0x8}; taskENTER_CRITICAL(); RS(false); DB(0x40 | 0x8); LCD_DELAY_WRITE; RS(true); for (int i = 0; i < sizeof(arrow); i++) { DB(arrow[i]); } Locate(0, 0); taskEXIT_CRITICAL(); }
static void WriteData(unsigned cmd) { unsigned fb=mDevID+RS(1)+RW(0); SCLK(1); SDI(1); CS(0); gdelay(1); writebyte(fb); writebyte(cmd); CS(1); }
void ReadConfig() { RS(flac_cfg.title.tag_format, sizeof(flac_cfg.title.tag_format), default_format); if (flac_cfg.title.tag_format_w) free(flac_cfg.title.tag_format_w); flac_cfg.title.tag_format_w = convert_ansi_to_wide_(flac_cfg.title.tag_format); /* @@@ FIXME: trailing spaces */ RS(flac_cfg.title.sep, sizeof(flac_cfg.title.sep), default_sep); RI(flac_cfg.tag.reserve_space, 1); RI(flac_cfg.display.show_bps, 1); RI(flac_cfg.output.misc.stop_err, 0); RI(flac_cfg.output.replaygain.enable, 1); RI(flac_cfg.output.replaygain.album_mode, 0); RI(flac_cfg.output.replaygain.hard_limit, 0); RI(flac_cfg.output.replaygain.preamp, 0); RI(flac_cfg.output.resolution.normal.dither_24_to_16, 0); RI(flac_cfg.output.resolution.replaygain.dither, 0); RI(flac_cfg.output.resolution.replaygain.noise_shaping, 1); RI(flac_cfg.output.resolution.replaygain.bps_out, 16); }
static int hx8352_val_get_value(void *data, u64 *val) { unsigned byte=mDevID+RS(1)+RW(1); CS(0); writebyte(byte); byte = readbyte(); //dummy byte = readbyte(); CS(1); *val = byte; printk("[LCDC] reg 0x%X=0x%x\n", regval, (unsigned)*val); return 0; }
static unsigned readreg(unsigned reg) { unsigned byte=mDevID+RS(1)+RW(1); WriteCommand(reg); mdelay(10); CS(0); writebyte(byte); byte = readbyte(); //dummy byte = readbyte(); CS(1); return byte; }
void LCD1602::Print(const char* string) { taskENTER_CRITICAL(); RS(true); while (*string) { DB(*string); string++; } taskEXIT_CRITICAL(); }
void config_read() { char variable_bitrate_display[10]; char priority[10]; char memmap_file[10]; char local_buffer_size[10]; char stream_buffer_size[10]; config_init(); strcpy(variable_bitrate_display, "1"); strcpy(priority, "4"); strcpy(memmap_file, "0"); strcpy(local_buffer_size, "128"); strcpy(stream_buffer_size, "64"); RS(variable_bitrate_display); RS(priority); RS(m_format_string); RS(memmap_file); RS(local_buffer_size); RS(stream_buffer_size); m_priority = atoi(priority); m_variable_bitrate_display = atoi(variable_bitrate_display); m_memmap_file = atoi(memmap_file); m_local_buffer_size = atoi(local_buffer_size); m_stream_buffer_size = atoi(stream_buffer_size); }
static PetscErrorCode KSPPGMRESBuildSoln(PetscScalar *nrs,Vec vguess,Vec vdest,KSP ksp,PetscInt it) { PetscScalar tt; PetscErrorCode ierr; PetscInt k,j; KSP_PGMRES *pgmres = (KSP_PGMRES*)(ksp->data); PetscFunctionBegin; /* Solve for solution vector that minimizes the residual */ if (it < 0) { /* no pgmres steps have been performed */ ierr = VecCopy(vguess,vdest);CHKERRQ(ierr); /* VecCopy() is smart, exits immediately if vguess == vdest */ PetscFunctionReturn(0); } /* solve the upper triangular system - RS is the right side and HH is the upper triangular matrix - put soln in nrs */ if (*HH(it,it) != 0.0) nrs[it] = *RS(it) / *HH(it,it); else nrs[it] = 0.0; for (k=it-1; k>=0; k--) { tt = *RS(k); for (j=k+1; j<=it; j++) tt -= *HH(k,j) * nrs[j]; nrs[k] = tt / *HH(k,k); } /* Accumulate the correction to the solution of the preconditioned problem in TEMP */ ierr = VecZeroEntries(VEC_TEMP);CHKERRQ(ierr); ierr = VecMAXPY(VEC_TEMP,it+1,nrs,&VEC_VV(0));CHKERRQ(ierr); ierr = KSPUnwindPreconditioner(ksp,VEC_TEMP,VEC_TEMP_MATOP);CHKERRQ(ierr); /* add solution to previous solution */ if (vdest == vguess) { ierr = VecAXPY(vdest,1.0,VEC_TEMP);CHKERRQ(ierr); } else { ierr = VecWAXPY(vdest,1.0,VEC_TEMP,vguess);CHKERRQ(ierr); } PetscFunctionReturn(0); }
/* Just used write commands while Initialization of CLCD */ void write(unsigned char bit_value) { unsigned char nibble; unsigned short wait; RS(LOW); for (nibble = 0; nibble < 2; nibble++) { LCD_PORT = (LCD_PORT & 0x0F) | ((bit_value << (4 * nibble)) & 0xF0); EN(1); for (wait = 1000; wait--; ); EN(0); } }
void InitLCD(void) { char d[] = {0x38, 0x38, 0x0C, 0x06, 0x01, 0x00}; int k; for(k = 0; k < 34; k++) { del3ms(); } RS(0); k = 0; while(d[k] != 0) { enviaLCD(d[k]); k++; } }
/** * jrs encoder for pipeline architecture * * @params env, jni env variable * @params jobj, jni obj variable * @params in, input data buffer, can transform to character array by `env->GetDirectBufferAddress(in)` * First `size*k` bytes are real data, followed by 4 bytes to indicate the seq number and 1 byte to * inidicate whether this is the end for a whole chunk * @params out, output data buffer, can transform to character array by `env->GetDirectBufferAddress(out)` * Need to reset before importing data. First `n*size` bytes are real output data, followed by 4 bytes * to indicate the seq number * @param k * @param m * @param blockSize, packet size(normally 1MB) * * @returns void * * @appendix, need to add cleanup code. */ JNIEXPORT void JNICALL Java_org_apache_hadoop_raid_JRSEncoder_00024JRSMigrationEncoder_jrsEncode (JNIEnv * env, jobject obj, jobject in, jobject out, jint k, jint m, jint blockSize){ //To get a byte array //Initialize a ProductMatrix Object RS rs=RS(k+m,k,8); rs.generate_encoding_matrix(); int whole_length=blockSize*k; jclass cls = env->GetObjectClass(obj); jmethodID mid1 = env->GetMethodID(cls, "take", "()V"); if (NULL == mid1) { return; } char * inData = (char*)(env)->GetDirectBufferAddress(in); //To push a byte array jmethodID mid2 = env->GetMethodID(cls, "push", "()V"); if (0 == mid2) { return; } char * outData = (char*)(env)->GetDirectBufferAddress(out); char flag; while(1){ env->CallVoidMethod(obj, mid1); memset(outData, 0, 64+m*blockSize); rs.encode2((char*)inData,(char*)outData,whole_length); memcpy(outData+m*blockSize,inData+whole_length,4); env->CallVoidMethod(obj, mid2); flag=inData[4+whole_length]; if(flag==1){ return; } } }
/* This function is to be called in Timer ISR */ void update_clcd_screen(void) { static unsigned char data = 0; static unsigned char nibble = 0; /* Start pushing the data on port only when the enable line is Low */ if(EN_PIN_LOW) { /* The below line is to change the line to be printed on CLCD */ /* The clcd_buff containes the line addresses of the CLCD on start */ RS(!!(data_offset % CLCD_LINE_LEN)); data = clcd_buff[data_offset / CLCD_LINE_LEN][data_offset % CLCD_LINE_LEN]; /* Send char data to the LCD */ if (nibble) { /* LSB nibble */ if ((data_offset + 1) < (NO_OF_LINES * CLCD_LINE_LEN)) { data_offset += 1; } else { /* Screen updated so no need of refreshing again */ update_clcd = 0; data_offset = 0; } LCD_PORT = (LCD_PORT & 0x0F) | ((data << 4) & 0xF0); } else { LCD_PORT = (LCD_PORT & 0x0F) | (data & 0xF0); } nibble = !nibble; } /* Once the data is on port, Enable the CLCD to process the data */ /* This line also makes sure that is enable pulse generated for two overflows */ EN(PIN_TOGGLE); }
int main() { spi_init(); pwm_init(); adc_init(); uint16_t current, voltage; for(;;) { char value = spi_transfer('k'); reswitch: switch(value) { case 'c': /* capabilities */ RS(spi_transfer('2')); /* 2 servos */ RS(spi_transfer('m')); /* voltage/current meters */ RS(spi_transfer('d')); /* done */ break; case 'm': /* read meters */ RS(spi_transfer(voltage)); RS(spi_transfer(current)); break; case 'k' /* okay? used to syncronize */ break; case '1': /* command channel */ case '2': { uint8_t hb, lb; RS((hb = spi_transfer('n'))); RS((lb = spi_transfer('n'))); int16_t cmd = ((uint16_t)hb << 8) | lb; pwm_set(value - '1', cmd); } break; } /* read current and voltage */ voltage = read_adc(0); } }
static int prp_open(const char* path, fuse_file_info* fi) { // Check if this is the special PageInfo file if (strcmp(path, "/" PAGEINFO) == 0) { fi->fh = 0; return 0; } // Get the type plString typeStr = plString(path + 1).beforeFirst('/'); if (typeStr.empty()) return -ENOENT; short type = plFactory::ClassIndex(typeStr); if (type < 0) return -ENOENT; // Make sure the object is actually present (O_CREAT is already handled) plString oname = plString(path + 1).afterFirst('/').beforeLast('.'); plKey myKey; std::vector<plKey> keys = RESMGR.getKeys(PAGE->getLocation(), type); for (std::vector<plKey>::iterator it = keys.begin(); it != keys.end(); it++) { if ((*it)->getName() == oname) myKey = *it; } if (!myKey.Exists()) return -ENOENT; // Look for an already-open object: for (FILELIST::iterator it = s_openfiles.begin(); it != s_openfiles.end(); it++) { if ((*it)->key == myKey) { if ((fi->flags & (O_RDWR | O_WRONLY)) != 0) return -EACCES; (*it)->ref(); fi->fh = (*it)->fh; return 0; } } // First time to open: FileCache* fc = new FileCache(); fc->key = myKey; // Cache the object raw data { hsRAMStream RS(RESMGR.getVer()); myKey->getObj()->write(&RS, &RESMGR); fc->objsize = RS.size(); fc->objdata = new unsigned char[fc->objsize]; RS.copyTo(fc->objdata, fc->objsize); } // Cache the PRC data { hsRAMStream RS(RESMGR.getVer()); pfPrcHelper prc(&RS); myKey->getObj()->prcWrite(&prc); fc->prcsize = RS.size(); fc->prcdata = new unsigned char[fc->prcsize]; RS.copyTo(fc->prcdata, fc->prcsize); } return 0; }