本文整理汇总了C++中readReg函数的典型用法代码示例。如果您正苦于以下问题:C++ readReg函数的具体用法?C++ readReg怎么用?C++ readReg使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readReg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readReg
void CMCP23017::dumpReg(const uint8_t nRegAddr)
{
uint8_t nRegVal = readReg(nRegAddr);
Serial.print("********** ");
Serial.print(getRegName(nRegAddr));
Serial.print(" = ");
Serial.print(nRegVal, BIN);
Serial.println(" **********");
}
示例2: writeReg
// should be called immediately after reception in case sender wants ACK
void RFM69::sendACK(const void* buffer, uint8_t bufferSize) {
uint8_t sender = SENDERID;
int16_t _RSSI = RSSI; // save payload received RSSI value
writeReg(REG_PACKETCONFIG2, (readReg(REG_PACKETCONFIG2) & 0xFB) | RF_PACKET2_RXRESTART); // avoid RX deadlocks
uint32_t now = millis();
while (!canSend() && millis() - now < RF69_CSMA_LIMIT_MS) receiveDone();
sendFrame(sender, buffer, bufferSize, false, true);
RSSI = _RSSI; // restore payload RSSI
}
示例3: get_rx_queue_num_pkts_dropped_bad
unsigned int get_rx_queue_num_pkts_dropped_bad(nf2device* nf2, unsigned char port) {
unsigned int retval = 0;
switch(port) {
case 0:
readReg(nf2, MAC_GRP_0_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &retval);
break;
case 1:
readReg(nf2, MAC_GRP_1_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &retval);
break;
case 2:
readReg(nf2, MAC_GRP_2_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &retval);
break;
case 3:
readReg(nf2, MAC_GRP_3_RX_QUEUE_NUM_PKTS_DROPPED_BAD_REG, &retval);
break;
}
return retval;
}
示例4: writeReg
int8_t RFM69OOK::readRSSI(bool forceTrigger) {
if (forceTrigger)
{
// RSSI trigger not needed if DAGC is in continuous mode
writeReg(REG_RSSICONFIG, RF_RSSI_START);
while ((readReg(REG_RSSICONFIG) & RF_RSSI_DONE) == 0x00); // Wait for RSSI_Ready
}
return -(readReg(REG_RSSIVALUE) >> 1);
}
示例5: read_info
/*
* Read the version info from the board
*/
void read_info( struct nf2device *nf2 )
{
int i;
// Read the version and revision
readReg(nf2, DEV_ID_DEVICE_ID, &nf2->info.nf2_device_id);
readReg(nf2, DEV_ID_REVISION, &nf2->info.nf2_revision);
// Read the version string
for (i = 0; i < DEVICE_STR_NUM_REGS; i++)
{
readReg(nf2, DEV_ID_DEV_STR_0 + i * 4, (unsigned *)(nf2->info.nf2_device_str + i * 4));
// Perform byte swapping if necessary
*(unsigned *)(nf2->info.nf2_device_str + i * 4) = ntohl(*(unsigned *)(nf2->info.nf2_device_str + i * 4));
}
nf2->info.nf2_device_str[DEVICE_STR_LEN - 1] = '\0';
}
示例6: writeReg
bool Acceleration_Sensor::init()
{
const unsigned char activeModeWith100Hz = (1 << 0) | (3 << 3); // Active Mode @ 100Hz
writeReg(Ctrl_Reg1, activeModeWith100Hz);
const char whoAmIReg = readReg(WhoAmI);
return (mWhoAmIExpectedValue == whoAmIReg);
}
示例7: readRam
unsigned short readRam (unsigned char reg)
{
//read ram space address
unsigned char hi,lo;
while (readReg (RAMSTAT)&0x01);//wait for indirect registers
writeReg(RAMADDR,reg) ;
while (readReg (RAMSTAT)&0x01);//wait for indirect registers
hi = readReg(RAMHI);
lo = readReg(RAMLO);
return (SixteenBit (hi,lo));
}
示例8: update
void update()//中断服务函数
{
uint8_t Asr_Count=0;
if((readReg(0x2b) & 0x10) && readReg(0xb2)==0x21 && readReg(0xbf)==0x35)//如果有语音识别中断、DSP闲、ASR正常结束
{
writeReg(0x29,0) ;///////////关中断
writeReg(0x02,0) ;/////////////关FIFO中断
Asr_Count = readReg(0xba);//读中断辅助信息
if(Asr_Count>0 && Asr_Count<4) //////如果有识别结果
{
readnum=readReg(0xc5);
readflag=1;
}
writeReg(0x2b,0);//////清楚中断编号
writeReg(0x1C,0);////////貌似关麦克风啊~~为毛
}
readReg(0x06);
delay(10);
readReg(0x06);
writeReg(0x89, 0x03);
delay(5);
writeReg(0xcf, 0x43);
delay(5);
writeReg(0xcb, 0x02);
writeReg(0x11, PLL_11);
writeReg(0x1e,0x00);
writeReg(0x19, PLL_ASR_19);
writeReg(0x1b, PLL_ASR_1B);
writeReg(0x1d, PLL_ASR_1D);
delay(10);
writeReg(0xcd, 0x04);
writeReg(0x17, 0x4c);
delay(5);
writeReg(0xcf, 0x4f);
writeReg(0xbd, 0x00);
writeReg(0x17, 0x48);
delay(10);
writeReg(0x3c, 0x80);
writeReg(0x3e, 0x07);
writeReg(0x38, 0xff);
writeReg(0x3a, 0x07);
writeReg(0x40, 0);
writeReg(0x42, 8);
writeReg(0x44, 0);
writeReg(0x46, 8);
delay(1);
writeReg(0x1c, 0x09);////////麦克风设置保留
writeReg(0xbd, 0x20);/////////保留设置
writeReg(0x08, 0x01);///////////→清除FIFO_DATA
delay( 1);
writeReg(0x08, 0x00);////////////清除指定FIFO后再写入一次00H
delay( 1);
writeReg(0xb2, 0xff);////////给0xB2写FF
writeReg(0x37, 0x06);////////开始识别
delay( 5 );
writeReg(0x1c, g_Mic);////////选择麦克风
writeReg(0x29, 0x10);////////开同步中断
writeReg(0xbd, 0x00);/////////启动为语音识别
}
示例9: cc1101Init
/*
* initialize CC1101
*/
void cc1101Init(uint8_t mode100k) {
cli();
bitSet(DDR_SPI, PIN_SPI_SS); // set B2(SS) as Output
bitSet(DDR_SPI, PIN_SPI_MOSI); // set B3(MOSI) as Output
bitClear(DDR_SPI, PIN_SPI_MISO); // set B4(MISO) as Input
bitSet(DDR_SPI, PIN_SPI_SCK); // set B5(SCK) as Output
bitClear(DDR_GDO0, PIN_GDO0); // set B2(SS) as Input
bitSet(PORT_SPI, PIN_SPI_SS); // set SS high
bitSet(PORT_SPI, PIN_SPI_SCK); // set SCK high
bitClear(PORT_SPI, PIN_SPI_MOSI); // set MOSI high
SPCR = _BV(SPE) | _BV(MSTR); // SPI speed = CLK/4
cc1101_Deselect(); // some deselect and selects to initialize the TRX868modul
_delay_us(30);
cc1101_Select();
_delay_us(30);
cc1101_Deselect();
_delay_us(45);
cmdStrobe(CC1101_SRES); // send reset
_delay_us(100);
for (uint8_t i=0; i<sizeof(initVal); i += 2) { // write initialize value to cc1101
writeReg(pgm_read_byte(&initVal[i]), pgm_read_byte(&initVal[i+1]));
}
if (mode100k) { // switch to 100k mode
for (uint8_t i=0; i<sizeof(initValUpdate); i += 2) { // write initialize value to cc1101
writeReg(
pgm_read_byte(&initValUpdate[i]),
pgm_read_byte(&initValUpdate[i+1])
);
}
}
cmdStrobe(CC1101_SCAL); // calibrate frequency synthesizer and turn it off
_delay_ms(4);
do {
cmdStrobe(CC1101_SRX);
} while (readReg(CC1101_MARCSTATE, CC1101_STATUS) != 0x0D);
writeReg(CC1101_PATABLE, PA_MaxPower); // configure PATABLE
cmdStrobe(CC1101_SRX); // flush the RX buffer
cmdStrobe(CC1101_SWORRST); // reset real time clock
_delay_ms(3);
sei();
}
示例10: startrx
static void startrx (u1_t rxmode) {
ASSERT( (readReg(RegOpMode) & OPMODE_MASK) == OPMODE_SLEEP );
if(getSf(LMIC.rps) == FSK) { // FSK modem
rxfsk(rxmode);
} else { // LoRa modem
rxlora(rxmode);
}
// the radio will go back to STANDBY mode as soon as the RX is finished
// or timed out, and the corresponding IRQ will inform us about completion.
}
示例11: if
void nRF24L01p::irqFunction(byte _mask,boolean _onoff){
byte buf=readReg(CONFIG);
if(_onoff==true){
buf|=0x70;
buf&=(~_mask | 0x0F);
}else if(_onoff==false){
buf|=(_mask & 0x70);
}
writeReg(CONFIG,buf);
}
示例12: starttx
// start transmitter (buf=LMIC.frame, len=LMIC.dataLen)
static void starttx () {
ASSERT( (readReg(RegOpMode) & OPMODE_MASK) == OPMODE_SLEEP );
if(getSf(LMIC.rps) == FSK) { // FSK modem
txfsk();
} else { // LoRa modem
txlora();
}
// the radio will go back to STANDBY mode as soon as the TX is finished
// the corresponding IRQ will inform us about completion.
}
示例13:
uint8_t EM2874Device::readReg (const uint8_t idx)
{
uint8_t val;
if(!readReg (idx, &val)) {
#ifdef DEBUG
*log << "readReg(" << (unsigned)idx << ") failed.";
#endif
}
return val;
}
示例14: cardSize
/**
* Determine the size of a standard SD flash memory card
* \return The number of 512 byte data blocks in the card
*/
uint32_t SdCard::cardSize(void)
{
uint16_t c_size;
csd_t csd;
if (!readReg(CMD9, (uint8_t *)&csd)) return 0;
uint8_t read_bl_len = csd.read_bl_len;
c_size = (csd.c_size_high << 10) | (csd.c_size_mid << 2) | csd.c_size_low;
uint8_t c_size_mult = (csd.c_size_mult_high << 1) | csd.c_size_mult_low;
return (uint32_t)(c_size+1) << (c_size_mult + read_bl_len - 7);
}
示例15: getPort
void CMCP23017::setOutput(const uint8_t nPin)
{
// Get value from MCP23017 port A if nPin is between 8 and 15 or from port B if nPin is between 0 and 7
uint8_t nPort = getPort(nPin, IODIRA, IODIRB),
nPortVal = readReg(nPort);
// Preserve all the bits except for the one corresponding to the pin that we are changing to input mode (1)
nPortVal &= ~getPinMask(nPin);
writeReg(nPort, nPortVal);
}