/** \brief Initialize and set cpu and periheral clocks. * * CPU clock frequencies set are: * -CPU: 32HMZ * -Peripheral Prescaling: NONE */ static void setup_clocks(void) { // set 32MHZ oscillator as CPU clock source CLKSYS_Enable(OSC_RC32MEN_bm); // enable do { nop(); } while (!CLKSYS_IsReady(OSC_RC32MRDY_bm)); // wait til stable CLKSYS_Main_ClockSource_Select(CLK_SCLKSEL_RC32M_gc); // select for CPU // disable all presacalers, until we decide otherwise CLKSYS_Prescalers_Config(CLK_PSADIV_1_gc, CLK_PSBCDIV_1_1_gc); // set up external 32KHz oscillator (NOTE: first param is ignored) CLKSYS_XOSC_Config(OSC_FRQRANGE_04TO2_gc, false, OSC_XOSCSEL_32KHz_gc); // set internal 32KHz oscillator as source for DFLL and autocalibrate 32MHz CLKSYS_Enable(OSC_XOSCEN_bm); //enable do { nop(); } while (!CLKSYS_IsReady(OSC_XOSCRDY_bm)); // wait til stable CLKSYS_AutoCalibration_Enable(OSC_RC32MCREF_bm, true); // true == ext 32KHz // disable unused oscillators (internal 2MHz and 32KHz oscillators) CLKSYS_Disable(OSC_RC2MEN_bm | OSC_RC32KEN_bm); }
// -- Soft USART void DelayTXBitUART (void) // p/ detalhes do delay veja no cabeçalho deste arquivo { Delay1KTCYx(1); Delay100TCYx(2); Delay10TCYx(2); nop() ; nop() ; nop() ; nop() ; nop() ; nop() ; nop() ; nop() ; }//
void AccelCalibration(void) { #ifdef STACCEL return; #else char value[9]; short avgOffset[3]; int i,j; g_idle = 1; // put the callback funciton on idle so it doesn't interrupt // set the Accelerometer to measurement mode value[0] = 5; WriteAccelData(0x16, value, 1); // clear out the old calibration values first!!!!!!!! g_calValues[0] = 0; g_calValues[1] = 0; g_calValues[2] = 0; value[0] = value[1] = value[2] = value[3] = value[4] = value[5] = 0; WriteAccelData(0x10, value, 6); usleep(200); for(j=0;j<10;j++){ // get a set of readings from the Accelerometer while(!PIO_Get(&(accIntPins[0]))){nop();} // wait for data ready pin ReadAccelData(0x0,value,9); // read in 9 bytes for both 10bit and 8bit for(i=0;i<3;i++){ avgOffset[i] = value[i*2+1]<<8; avgOffset[i] |= value[i*2]; if(avgOffset[i] > 512) avgOffset[i] -=1024; g_calValues[i] += avgOffset[i]; // sum up values } usleep(100000); } // take the average g_calValues[0] /= 10; g_calValues[1] /= 10; g_calValues[2] /= 10; // multiply the offsets by 2, stated in the datasheet unsure why has to do with 1/2 LSB g_calValues[0] = -g_calValues[0]*2; g_calValues[1] = -g_calValues[1]*2; g_calValues[2] = (64 - g_calValues[2])*2; // write data to offset register AccelSetCalibration(); g_idle = 0; // turn back on the callback #endif }
/** \brief Samples the ADC once, blocking until conversion is complete. * * Calling this function while the ADC is in continuous sample mode will * disable continuous conversions, perform an additional conversion, and return * the result This is to prevent the function from busy waiting indefinetely * for the ADC to be ready for a new conversion, as conversions are being * continously initiated by the ADC_EOC_interrupt_handler() from the user's ISR * in continuous mode. * * \param[in] adc the ADC to start a conversion on * * \return conversion result */ uint16_t ADC_sample_once(ADC_ext_t *adc) { /* stop continuous conversions, if they are ongoing */ adc->continuous = false; /* wait for an ongoing convrsion to finish */ while (!adc->ready){ nop(); } /* start a conversion */ adc->ready = false; adc->control_port->OUTCLR = adc->CONVST_bm; delay_ms(1); // if ADC stops working, try uncommenting this line adc->control_port->OUTSET = adc->CONVST_bm; /* wait for conversion to finish */ while (!adc->ready){ nop(); } return ADC_get_last_result(adc); }
static uint8_t psb2186_read(uint8_t addr) { PIN_CLEAR(PSB2186_CS); DDRA = 0xFF; PORTA = addr; PIN_SET(PSB2186_ALE); nop(); PIN_CLEAR(PSB2186_ALE); DDRA = 0; PORTA = 0; PIN_CLEAR(PSB2186_RD); nop(); uint8_t byte = PINA; PIN_SET(PSB2186_RD); PIN_SET(PSB2186_CS); return byte; }
void Interrupt_OEI3(void) { #ifdef DEVICE_PACKAGE_TFLGA_85 /* This peripheral is not available on the 85-pin package */ nop(); #else /* Call the user function */ if (rpdl_POE_callback_func[1] != PDL_NO_FUNC) { rpdl_POE_callback_func[1](); } #endif }
void SST25VF::totalErase() { SPI.beginTransaction(sstSPISettings); digitalWrite(FLASH_SSn,LOW); SPI.transfer(0x06);//write enable instruction digitalWrite(FLASH_SSn,HIGH); nop(); digitalWrite(FLASH_SSn, LOW); (void) SPI.transfer(0x60); // Erase Chip // digitalWrite(FLASH_SSn, HIGH); waitUntilDone(); SPI.endTransaction();; }
/* * This function demonstrates use of the dummy_driver to configure * the SPI and send an initialization message over the SPI bus. * */ int main(void) { /* Configure this device as the master on the SPI bus */ configureSpiMaster(); /* Send an initialization message to the slave peripheral over the SPI bus */ sendInitComplete(); while (1) { nop(); } }
unsigned char WriteAccelData(unsigned int iaddress, char *bytes, unsigned int num) { unsigned int timeout; // wait for TWI bus to be ready while(!(TWI_TransferComplete(AT91C_BASE_TWI))) nop(); // Start Writing TWI_StartWrite(AT91C_BASE_TWI,ACCELADDR,iaddress,1,*bytes++); num--; while(num > 0){ // Wait before sending the next byte timeout = 0; while(!TWI_ByteSent(AT91C_BASE_TWI) && (++timeout<TWITIMEOUTMAX)) nop(); if(timeout == TWITIMEOUTMAX) return 1; TWI_WriteByte(AT91C_BASE_TWI, *bytes++); num--; } return 0; }
void Interrupt_IRQ7(void) { #ifdef DEVICE_PACKAGE_TFLGA_85 /* This pin is not available on the 85-pin package */ nop(); #else /* Call the user function */ if (rpdl_INTC_callback_func[PDL_INTC_IRQ7] != PDL_NO_FUNC) { rpdl_INTC_callback_func[PDL_INTC_IRQ7](); } #endif }
void SST25VF::totalErase() { enable(); digitalWrite(FLASH_SSn,LOW); SPI.transfer(0x06);//write enable instruction digitalWrite(FLASH_SSn,HIGH); nop(); digitalWrite(FLASH_SSn, LOW); (void) SPI.transfer(0x60); // Erase Chip // digitalWrite(FLASH_SSn, HIGH); waitUntilDone(); disable(); }
/*FIXME: TRUTH???^^^^*/ void pause(BYTE max) { BYTE ofst; BYTE count; for (count = 0; count < max; count++) { /* this delays for .5 msec */ //FIXME:TRUTH?^^^^^^^ for (ofst = 0; ofst < 97; ofst++) nop(); } }
void WriteNibble(unsigned char data) { unsigned char temp = 0; LATA = 0x00; // RS = 0; // RW = 0; TRISD &= 0xF0; // Make output; nop(); nop(); temp = data>>4; // Take High Nibble temp &= 0x0F; LATA |= 0x02; // LCD_EN = 1; LATD = temp; // Write High Nibble to PORTD (LATD) nop(); nop(); nop(); LATA &= 0x00; // LCD_EN = 0; // NOTE: Since low Nibble is zero and also // LCD will write always first to High Nibble and Low nibble will be zero unless written }
static void reset_controller(void) { int i; outb(4, HD_CMD); for (i = 0; i < 1000; i++) nop(); outb(0, HD_CMD); for (i = 0; i < 10000 && drive_busy(); i++); /* nothing */ if (drive_busy()) printk("HD-controller still busy\n\r"); if ((i = inb(HD_STATUS)) & ERR_STAT) printk("HD-controller reset failed: %02x\n\r"); }
void Interrupt_EXDMAC1(void) { #if defined(DEVICE_PACKAGE_LQFP_100) || defined(DEVICE_PACKAGE_TFLGA_85) /* This peripheral is not available on the 100-pin or 85-pin packages */ nop(); #else /* Call the user function */ if (rpdl_EXDMAC_callback_func[1] != PDL_NO_FUNC) { rpdl_EXDMAC_callback_func[1](); } #endif }
static void writer(int pa, int reg, u16 dat) { u32 a; a = 0; a |= Mgmiireg & (reg << Offr); a |= Gmiiwrite; a |= (pa << 10) & Mgmiipa; a |= Csrclkrng; a |= Gmiibusy; while (R(offadd) & Gmiibusy) nop(); R(offadd) = a; while (R(offadd) & Gmiibusy) nop(); R(offdat) = dat; R(offadd) = a; while (R(offadd) & Gmiibusy) nop(); }
void SST25VF::waitUntilDone() { uint8_t data = 0; while (1) { digitalWrite(FLASH_SSn,LOW); (void) SPI.transfer(0x05); data = SPI.transfer(0); digitalWrite(FLASH_SSn,HIGH); if (!bitRead(data,0)) break; nop(); } }
int main () { cout<<""<<endl; cout<<""<<endl; cout<<"**Welcome to the Connect Four Program**"<<endl; cout<<""<<endl; void nop(); nop(); humanmove(); win(); return 0; }
int main( void ) { /* Assume that everything is ok*/ success = true; /* Before using the AES it is recommended to do an AES software reset to put * the module in known state, in case other parts of your code has accessed * the AES module. */ AES_software_reset(); /* Generate last subkey. */ AES_lastsubkey_generate(key, lastsubkey); /* Do AES Cipher Block Chaining encryption and decryption on three blocks. */ success = AES_CBC_encrypt(); /* MODIFY THE FUNCTION CALL */ success = AES_CBC_decrypt(); /* MODIFY THE FUNCTION CALL */ /* Check if decrypted answer is equal to plaintext. */ for(uint8_t i = 0; i < BLOCK_LENGTH * BLOCK_COUNT ; i++ ){ if (data_block[i] != block_ans[i]){ success = false; } } if(success){ while(true){ /* If the example ends up here every thing is ok. */ nop(); } }else{ while(true){ /* If the example ends up here something is wrong. */ nop(); } } }
static void prvTimer2IntHandler( void ) { volatile unsigned short usCurrentCount; static unsigned short usMaxCount = 0; static unsigned long ulErrorCount = 0UL; /* We use the timer 1 counter value to measure the clock cycles between the timer 0 interrupts. First stop the clock. */ CMT.CMSTR1.BIT.STR3 = 0; nop(); nop(); usCurrentCount = timerTIMER_3_COUNT_VALUE; /* Is this the largest count we have measured yet? */ if( usCurrentCount > usMaxCount ) { if( usCurrentCount > timerEXPECTED_DIFFERENCE_VALUE ) { usMaxJitter = usCurrentCount - timerEXPECTED_DIFFERENCE_VALUE; } else { /* This should not happen! */ ulErrorCount++; } usMaxCount = usCurrentCount; } /* Used to generate the run time stats. */ ulHighFrequencyTickCount++; /* Clear the timer. */ timerTIMER_3_COUNT_VALUE = 0; /* Then start the clock again. */ CMT.CMSTR1.BIT.STR3 = 1; }
uint8_t xram_read(uint16_t addr) { uint8_t data; /* Set HIGH before switching to output to prevent RD cycle */ XRAM_CTRL_PORT |= XRAM_RD; XRAM_CTRL_DDR |= XRAM_RD; /* Set HIGH before switching to output to prevent WR cycle */ XRAM_CTRL_PORT |= XRAM_WR; XRAM_CTRL_DDR |= XRAM_WR; PORTB = (uint8_t)(0x00FF & addr); DDRB = 0xFF; PORTC = (uint8_t)(0x000F & (addr >> 8)); DDRC |= 0x0F; PORTD = (uint8_t)(0x00F0 & (addr >> 8)); DDRD |= 0xF0; XRAM_ALE_DDR |= XRAM_ALE_PIN; XRAM_ALE_PORT |= XRAM_ALE_PIN; nop(); nop(); XRAM_ALE_PORT &= ~XRAM_ALE_PIN; /* Read a character from the fifo address. */ XRAM_DATA_SETINP(); XRAM_CTRL_RD_LO(); nop(); nop(); data = XRAM_DATA_PIN; XRAM_CTRL_RD_HI(); return data; }
static int pic32_wdt_stop(struct watchdog_device *wdd) { struct pic32_wdt *wdt = watchdog_get_drvdata(wdd); writel(WDTCON_ON, PIC32_CLR(wdt->regs + WDTCON_REG)); /* * Cannot touch registers in the CPU cycle following clearing the * ON bit. */ nop(); return 0; }
void convertValAD() { ADCON0.0=1; //ENABLE ADC timerDelay(80); ADCON0.1=1; //START ADC //vent til konvertering er afsluttet while(!ADCON0.1) nop(); //Vi gemmer vores v¾rdi i variablen valAD. valAD = ADRESH*256+ADRESL; }
extern "C" CVC_Exp CVC_ExpApply(CVC_VC vc, CVC_Op op, CVC_Exp *args, int num_args) { GetVC; try { CVC3::Op nop(FromExp(op).getOp()); std::vector<CVC3::Expr> cvc_args; for (int i = 0; i < num_args; i++) cvc_args.push_back(FromExp(args[i])); return ToExp(cvc->funExpr(nop, cvc_args)); } catch (CVC3::Exception ex) { ExceptionFail(ex); } }
// Endless loop of LED_A (PA0) blinks for error diagnosis. // Will blink code-many times and then make a longer delay. void PanicBlinker(uint8 code) { // Be sure to enable the output so that we can also diagnose // crashes which happen early. volatile AT91PS_PIO pPIO = AT91C_BASE_PIOA; pPIO->PIO_PER |= LED_A; pPIO->PIO_OER |= LED_A; pPIO->PIO_SODR = LED_A; for(;;) { uint8 i; unsigned int j; for(i=0; i<code; i++) { pPIO->PIO_CODR = LED_A; // LOW = turn LED on. for(j=PANIC_RATE; j; j--) nop(); pPIO->PIO_SODR = LED_A; // HIGH = turn LED off. for(j=PANIC_RATE; j; j--) nop(); } for(j=PANIC_RATE*3; j; j--) nop(); } }
bool OBS::ProcessFrame(FrameProcessInfo &frameInfo) { List<DataPacket> videoPackets; List<PacketType> videoPacketTypes; //------------------------------------ // encode bufferedTimes << frameInfo.frameTimestamp; VideoSegment curSegment; bool bProcessedFrame, bSendFrame = false; VOID *picIn; //profileIn("call to encoder"); if (bShutdownEncodeThread) picIn = NULL; else picIn = frameInfo.pic->picOut ? (LPVOID)frameInfo.pic->picOut : (LPVOID)frameInfo.pic->mfxOut; videoEncoder->Encode(picIn, videoPackets, videoPacketTypes, bufferedTimes[0]); bProcessedFrame = (videoPackets.Num() != 0); //buffer video data before sending out if(bProcessedFrame) { bSendFrame = BufferVideoData(videoPackets, videoPacketTypes, bufferedTimes[0], curSegment); bufferedTimes.Remove(0); } else nop(); //profileOut; //------------------------------------ // upload profileIn("sending stuff out"); //send headers before the first frame if not yet sent if(bSendFrame) SendFrame(curSegment, frameInfo.firstFrameTime); profileOut; return bProcessedFrame; }
void test_nop_should_do_nothing_but_throw_exception_for_invalid_operand1(){ CEXCEPTION_T operandERR; Bytecode code = {.instruction = {.mnemonic = NOP, .name = "nop"}, .operand1 = 123, .operand2 = -1, .operand3 = -1, .absoluteAddress = 0x00 }; Try{ nop(&code); }Catch(operandERR){ TEST_ASSERT_EQUAL(ERR_INVALID_OPERAND1,operandERR); } TEST_ASSERT_EQUAL_HEX8(0x00, code.absoluteAddress); }
unsigned char ReadAccelData(unsigned int iaddress, char *bytes, unsigned int num) { unsigned int timeout; // wait for TWI bus to be ready while(!(TWI_TransferComplete(AT91C_BASE_TWI))) nop(); // Start Reading TWI_StartRead(AT91C_BASE_TWI, ACCELADDR,iaddress,1); while (num > 0) { // Last byte if(num == 1) TWI_Stop(AT91C_BASE_TWI); // wait for byte then read and store it timeout = 0; while(!TWI_ByteReceived(AT91C_BASE_TWI) && (++timeout<TWITIMEOUTMAX)) nop(); if(timeout == TWITIMEOUTMAX) return 2; *bytes++ = TWI_ReadByte(AT91C_BASE_TWI); num--; } return 0; }
void can_tx_buffer(){ // Wait for pending messages to be sent while(can_read_reg(TXB0CTRL)& 0x08){ nop(); } // Load the number of bytes to transmit can_write_bits(TXB0DLC, can_tx_pointer, 0x0F); // Request transmission can_write_cmd(0x81); return; }
void vAssertCalled( void ) { volatile unsigned long ul = 0; taskENTER_CRITICAL(); { /* Set ul to a non-zero value using the debugger to step out of this function. */ while( ul == 0 ) { nop(); } } taskEXIT_CRITICAL(); }