void nRF24L01::enablePipe(int pipe, uint8_t *addr, boolean aa) { uint8_t pw = 0x03; regSet(REG_EN_RXADDR, pipe); regWrite(REG_SETUP_AW, &pw, 1); regWrite(REG_RX_ADDR_P0 + pipe, addr, 5); regWrite(REG_RX_PW_P0 + pipe, &_pipeWidth, 1); if (aa) { regSet(REG_EN_AA, pipe); } else { regClr(REG_EN_AA, pipe); } }
void nRF24L01::setDataRate(uint8_t mhz) { switch (mhz) { case RATE_1MHZ: regClr(REG_RF_SETUP, 3); break; case RATE_2MHZ: regSet(REG_RF_SETUP, 3); break; } }
void __attribute__ ((naked)) a11Entry() { __asm__ ( "CPSID aif\n\t" //Disable interrupts "ldr r0,=_stack\n\t" "mov sp, r0" ); regSet(); }
void nRF24L01::setTXPower(uint8_t power) { switch (power) { case RF_TX_18DBM: regClr(REG_RF_SETUP, 1); regClr(REG_RF_SETUP, 2); break; case RF_TX_12DBM: regSet(REG_RF_SETUP, 1); regClr(REG_RF_SETUP, 2); break; case RF_TX_6DBM: regSet(REG_RF_SETUP, 1); regClr(REG_RF_SETUP, 2); break; case RF_TX_0DBM: regSet(REG_RF_SETUP, 1); regSet(REG_RF_SETUP, 2); break; } }
void nRF24L01::begin(uint8_t ad0, uint8_t ad1, uint8_t ad2, uint8_t ad3, uint8_t ad4, uint8_t chan, uint8_t width) { _spi->begin(); _spi->setSpeed(10000000UL); _addr[0] = ad0; _addr[1] = ad1; _addr[2] = ad2; _addr[3] = ad3; _addr[4] = ad4; _pipeWidth = width; pinMode(_csn, OUTPUT); pinMode(_ce, OUTPUT); pinMode(_intr, INPUT); digitalWrite(_csn, HIGH); digitalWrite(_ce, HIGH); setChannel(chan); regSet(REG_CONFIG, 2); uint8_t zero = 0x00; regWrite(REG_EN_AA, &zero, 1); _bc[0] = 0xFF; _bc[1] = 0xFF; _bc[2] = 0xFF; _bc[3] = 0xFF; _bc[4] = 0xFF; enablePipe(0, _bc, false); enablePipe(1, _addr, true); selectRX(); switch (isrHandlerCounter) { case 0: isrObject0 = this; attachInterrupt(_intr, nRF24L01_isrHandler0, FALLING); break; case 1: isrObject1 = this; attachInterrupt(_intr, nRF24L01_isrHandler1, FALLING); break; case 2: isrObject2 = this; attachInterrupt(_intr, nRF24L01_isrHandler2, FALLING); break; case 3: isrObject3 = this; attachInterrupt(_intr, nRF24L01_isrHandler3, FALLING); break; case 4: isrObject4 = this; attachInterrupt(_intr, nRF24L01_isrHandler4, FALLING); break; case 5: isrObject5 = this; attachInterrupt(_intr, nRF24L01_isrHandler5, FALLING); break; case 6: isrObject6 = this; attachInterrupt(_intr, nRF24L01_isrHandler6, FALLING); break; case 7: isrObject7 = this; attachInterrupt(_intr, nRF24L01_isrHandler7, FALLING); break; } isrHandlerCounter++; uint32_t s = disableInterrupts(); digitalWrite(_csn, LOW); _status = _spi->transfer(CMD_TX_FLUSH); digitalWrite(_csn, HIGH); digitalWrite(_csn, LOW); _status = _spi->transfer(CMD_RX_FLUSH); digitalWrite(_csn, HIGH); restoreInterrupts(s); uint8_t isrstat = 0x70; regWrite(REG_STATUS, &isrstat, 1); isrstat = 0xFF; regWrite(REG_SETUP_RETR, &isrstat, 1); enablePower(); }
void nRF24L01::enablePower() { regSet(REG_CONFIG, 1); }
void nRF24L01::selectRX() { _mode = 0; regSet(REG_CONFIG, 0); digitalWrite(_ce, HIGH); }
void Exporter::writeConfig(Interface *i) { if (mUseRegistry) { HKEY hKey; if (RegCreateKey(HKEY_CURRENT_USER, REGPATH, &hKey) != ERROR_SUCCESS) return; regSet(hKey, _T("npx_ver"), mVersion); regSet(hKey, _T("npx_tristrips"), mTriStrips); regSet(hKey, _T("npx_hidden"), mExportHidden); regSet(hKey, _T("npx_furn"), mExportFurn); regSet(hKey, _T("npx_lights"), mExportLights); regSet(hKey, _T("npx_vcolors"), mVertexColors); // regSet(hKey, "npx_wthresh", mWeldThresh); regSet(hKey, _T("npx_tprefix"), mTexPrefix); regSet(hKey, _T("npx_coll"), mExportCollision); regSet(hKey, _T("npx_remap"), mRemapIndices); RegCloseKey(hKey); } else { TCHAR iniName[MAX_PATH]; GetIniFileName(iniName); SetIniValue(NifExportSection, _T("GenerateStrips"), mTriStrips, iniName); SetIniValue(NifExportSection, _T("IncludeHidden"), mExportHidden, iniName); SetIniValue(NifExportSection, _T("FurnatureMarkers"), mExportFurn, iniName); SetIniValue(NifExportSection, _T("Lights"), mExportLights, iniName); SetIniValue(NifExportSection, _T("VertexColors"), mVertexColors, iniName); SetIniValue(NifExportSection, _T("TexturePrefix"), mTexPrefix, iniName); SetIniValue(NifExportSection, _T("ExportCollision"), mExportCollision, iniName); SetIniValue(NifExportSection, _T("RemapIndices"), mRemapIndices, iniName); SetIniValue(NifExportSection, _T("ExportExtraNodes"), mExportExtraNodes, iniName); SetIniValue(NifExportSection, _T("ExportSkin"), mExportSkin, iniName); SetIniValue(NifExportSection, _T("UserPropBuffer"), mUserPropBuffer, iniName); SetIniValue(NifExportSection, _T("FlattenHierarchy"), mFlattenHierarchy, iniName); SetIniValue(NifExportSection, _T("RemoveUnreferencedBones"), mRemoveUnreferencedBones, iniName); SetIniValue(NifExportSection, _T("SortNodesToEnd"), mSortNodesToEnd, iniName); SetIniValue(NifExportSection, _T("SkeletonOnly"), mSkeletonOnly, iniName); SetIniValue(NifExportSection, _T("Cameras"), mExportCameras, iniName); SetIniValue(NifExportSection, _T("GenerateBoneCollision"), mGenerateBoneCollision, iniName); SetIniValue(NifExportSection, _T("ExportTransforms"), mExportTransforms, iniName); SetIniValue<int>(NifExportSection, _T("ExportType"), mExportType, iniName); SetIniValue<float>(KfExportSection, _T("Priority"), mDefaultPriority, iniName); SetIniValue(NifExportSection, _T("MultiplePartitions"), mMultiplePartitions, iniName); SetIniValue<int>(NifExportSection, _T("BonesPerVertex"), mBonesPerVertex, iniName); SetIniValue<int>(KfExportSection, _T("BonesPerPartition"), mBonesPerPartition, iniName); //SetIniValue(NifExportSection, "UseTimeTags", mUseTimeTags, iniName); SetIniValue(NifExportSection, _T("AllowAccum"), mAllowAccum, iniName); SetIniValue(NifExportSection, _T("CollapseTransforms"), mCollapseTransforms, iniName); SetIniValue(NifExportSection, _T("ZeroTransforms"), mZeroTransforms, iniName); SetIniValue(NifExportSection, _T("FixNormals"), mFixNormals, iniName); SetIniValue(NifExportSection, _T("TangentAndBinormalExtraData"), mTangentAndBinormalExtraData, iniName); SetIniValue(NifExportSection, _T("UseAlternateStripper"), mUseAlternateStripper, iniName); SetIniValue(NifExportSection, _T("TangentAndBinormalMethod"), mTangentAndBinormalMethod, iniName); SetIniValue(NifExportSection, _T("StartNifskopeAfterStart"), mStartNifskopeAfterStart, iniName); //SetIniValue(CollisionSection, "bhkScaleFactor", bhkScaleFactor, iniName); SetIniValue<std::wstring>(NifExportSection, _T("Creator"), mCreatorName, iniName); SetIniValue(NifExportSection, _T("GeneratePartitionStrips"), mTriPartStrips, iniName); SetIniValue(NifExportSection, _T("WeldVertexThresh"), mWeldThresh, iniName); SetIniValue(NifExportSection, _T("WeldVertexThresh"), mNormThresh, iniName); SetIniValue(NifExportSection, _T("WeldUVWThresh"), mUVWThresh, iniName); SetIniValue<std::wstring>(NifExportSection, _T("RootType"), mRootType, iniName); } }
void __attribute__ ((naked)) a11Entry() { __asm__ ("ldr r0,=_stack\n\t mov sp, r0"); regSet(); }
/* * regRead * Open the specified registory. * Mode options are:- * * default - Exists in memory * meREGMODE_RELOAD - Delete the existing file, * meREGMODE_MERGE - Merge the existing file. */ meRegNode * regRead(meUByte *rname, meUByte *fname, int mode) { meLine hlp, *lp ; meUByte *fn ; meRegNode *rnp; /* Root node pointer */ meUInt flags ; /* Find the registry entry */ if(*rname == '/') rname++; if ((rnp = rnodeFind (&root, rname)) != NULL) { /* if not merging or reloading then we've can use the existing node */ if (!(mode & (meREGMODE_MERGE|meREGMODE_RELOAD))) goto finished; fn = rnp->value ; } else fn = NULL ; if(mode & meREGMODE_FROOT) { /* find the registry file */ /* have we been given a valid file name ? */ if ((fname != NULL) && (fname [0] != '\0')) { meUByte filename[meBUF_SIZE_MAX] ; /* Filename */ if(fileLookup(fname,(meUByte *)".erf",meFL_CHECKDOT|meFL_USESRCHPATH,filename)) fn = meStrdup(filename) ; else fn = meStrdup(fname) ; } /* else use the old file name (if there is one) else fail */ else if(fn == NULL) { mlwrite(MWABORT|MWWAIT,(meUByte *)"[No file name given to load]") ; return NULL ; } /* Load in the registry file */ flags = meRWFLAG_SILENT ; hlp.next = &hlp ; hlp.prev = &hlp ; if(mode & meREGMODE_CRYPT) { meUByte s1[meBUF_SIZE_MAX], *s2 ; int len ; meCrypt(NULL,0); meStrcpy(s1,getFileBaseName(fn)) ; len = meStrlen(s1) + 1 ; meCrypt(s1,len) ; if((s2=meUserName) == NULL) s2 = (meUByte *) "" ; meStrcpy(s1+len,s2) ; meCrypt(s1,len+meStrlen(s1+len)+1) ; flags |= meRWFLAG_CRYPT ; } if((ffReadFile(fn,flags,NULL,&hlp,0,0,0) == meABORT) && !(mode & meREGMODE_CREATE)) { mlwrite (MWABORT|MWWAIT,(meUByte *)"[Cannot load registry file %s]", fname); return NULL ; } lp = &hlp ; } else lp = frameCur->bufferCur->baseLine ; if ((rnp != NULL) && (mode & meREGMODE_RELOAD)) { /* Want to replace with new one. so delete old */ if(fn == rnp->value) rnp->value = NULL ; rnodeUnlink (rnp); rnodeDelete (rnp); rnp = NULL; } /* Construct the node for the file node */ if (rnp == NULL) { /* Construct the node */ if((rnp = regSet (&root, rname, NULL)) == NULL) return NULL ; rnp->mode = 0; } /* set the new file name */ if(rnp->value != fn) { meNullFree(rnp->value) ; rnp->value = fn ; } /* Now parse the registry file */ parseFile(rnp, lp) ; if(mode & meREGMODE_FROOT) meLineLoopFree(lp,0) ; finished: rnp->mode |= mode & meREGMODE_STORE_MASK ; return rnp ; }
/* * setRegistry * Assign a new value to the registry */ int setRegistry (int f, int n) { meUByte buf1[meBUF_SIZE_MAX], *name ; meUByte buf2[meBUF_SIZE_MAX] ; meRegNode *rnp, *pnp, *nnp ; /* Get the arguments */ if(meGetString((meUByte *)"Registry Path", 0, 0, buf1, meBUF_SIZE_MAX) == meABORT) return meABORT; if(n & 0x02) { if(((rnp = regFind(&root,buf1)) == NULL) || (rnp == &root)) return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot find node %s]",buf1); /* setting the name of the node, not the value */ if(meGetString((meUByte *)"name", 0, 0, buf2, meBUF_SIZE_MAX) == meABORT) return meABORT; if(((name=meStrrchr(buf2,'/')) != NULL) && (name[1] == '\0')) { *name = '\0' ; name = meStrrchr(buf2,'/') ; } if(name != NULL) { *name++ = '\0' ; if((pnp = regFind(&root,buf2)) == NULL) return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot find node %s]",buf2) ; nnp = pnp ; do { if(nnp == rnp) return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot move node to itself or one of its children]") ; } while((nnp=nnp->parent) != NULL) ; } else { name = buf2 ; pnp = rnp->parent ; } if((pnp != rnp->parent) || meStrcmp(name,rnp->name)) { if((name[0] == '\0') || (regFind(pnp,name) != NULL)) return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot set registry node]"); if((nnp = rnodeNew(name)) == NULL) return meABORT; rnodeUnlink(rnp) ; nnp->value = rnp->value ; nnp->child = rnp->child ; nnp->mode = rnp->mode ; meFree(rnp) ; rnodeLink(pnp,nnp) ; rnp = nnp->child ; while(rnp != NULL) { rnp->parent = nnp ; rnp = rnp->next ; } } } else { if(meGetString((meUByte *)"Value", 0, 0, buf2, meBUF_SIZE_MAX) == meABORT) return meABORT; /* Assigns the new value */ if(regSet(&root,buf1,buf2) == NULL) return mlwrite(MWCLEXEC|MWABORT,(meUByte *)"[Cannot set registry node]"); } return meTRUE; }