static int ad_resume(struct platform_device *pdev) { struct ad7877 *ad = platform_get_drvdata(pdev); ssp_restore_state(&ad->ssp, &ad->suspend_state); initChip(ad); return 0; }
int16_t main(void) { InitUSB(); // initialize the USB registers and serial interface engine initChip(); initMotor(); led_on(&led1); timer_setPeriod(LED_TIMER, 0.5); //start internal clock with defined period timer_start(LED_TIMER); pin_write(IN1, 1); pin_write(IN2, 0); pin_write(D2, 65536*2/5); while (USB_USWSTAT!=CONFIG_STATE) { // while the peripheral is not configured... ServiceUSB(); // ...service USB requests } while (1) { ServiceUSB(); // service any pending USB requests //LED1 TOGGLE TO CONFIRM RUNNING CODE if (timer_flag(LED_TIMER)) { timer_lower(LED_TIMER); led_toggle(&led1); pin_write(D2, VAL1); } } }
void TICC1100::initDevice() { try { openDevice(); if(!_fileDescriptor || _fileDescriptor->descriptor == -1) return; initChip(); _out.printDebug("Debug: CC1100: Setting GPIO direction"); setGPIODirection(1, GPIODirection::IN); _out.printDebug("Debug: CC1100: Setting GPIO edge"); setGPIOEdge(1, GPIOEdge::BOTH); openGPIO(1, true); if(!_gpioDescriptors[1] || _gpioDescriptors[1]->descriptor == -1) throw(BaseLib::Exception("Couldn't listen to rf device, because the gpio pointer is not valid: " + _settings->device)); if(gpioDefined(2)) //Enable high gain mode { openGPIO(2, false); if(!getGPIO(2)) setGPIO(2, true); closeGPIO(2); } } catch(const std::exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(BaseLib::Exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(...) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__); } }
int main() { chip8 chip; initChip(&chip); requestRom(&chip); runEmulator(&chip); return 0; }
void main() { initChip(); initTimer(); while(1) //Endless loop { PORTB = counter ; //Give value to PORTB } }
static int ad_probe(struct platform_device *pdev) { struct ad7877_platform_data *pdata = pdev->dev.platform_data; struct ad7877 *ad; int ret; int i; // Initialize ad data structure. ad = kzalloc(sizeof(*ad), GFP_KERNEL); if (!ad) return -ENOMEM; init_completion(&ad->comp); ret = request_irq(pdata->dav_irq, davirq , IRQF_DISABLED | IRQF_TRIGGER_FALLING , "ad7877-dav", ad); if (ret) { kfree(ad); return ret; } ret = ssp_init(&ad->ssp, 1, 0); if (ret) { printk(KERN_ERR "Unable to register SSP handler!\n"); free_irq(pdata->dav_irq, ad); kfree(ad); return ret; } platform_set_drvdata(pdev, ad); ssp_disable(&ad->ssp); ssp_config(&ad->ssp, SSCR0_DataSize(16), 0, 0, SSCR0_SerClkDiv(6)); ssp_enable(&ad->ssp); initChip(ad); for (i = 0; i < ARRAY_SIZE(acdevs); i++) { acdevs[i].sense = sense; ret = adc_classdev_register(&pdev->dev, &acdevs[i]); if (ret) { printk("ad7877: failed to register adc class " "device %s\n", acdevs[i].name); goto adc_cdev_register_failed; } } return 0; adc_cdev_register_failed: while (--i >= 0) adc_classdev_unregister(&acdevs[i]); return ret; }
void LiquidCrystalNew_SSPI::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { pinMode(_cs,OUTPUT); pinMode(_clk,OUTPUT); pinMode(_mosi,OUTPUT); #if defined(__FASTSWRITE2__) BLOCK_IRQS(); sclkport = digitalPinToPort(_clk); sclkpin = digitalPinToBitMask(_clk); mosiport = digitalPinToPort(_mosi); mosipin = digitalPinToBitMask(_mosi); csport = digitalPinToPort(_cs); cspin = digitalPinToBitMask(_cs); *portOutputRegister(csport) |= cspin;//hi ENABLE_IRQS(); #else digitalWrite(_cs, HIGH); #endif // ---- now prepare GPIO chip and initialize it if (_adrs > 0 && _adrs < 255){ writeByte(0x05,0b00101000);//HAEN -> ON (IOCON) } else { writeByte(0x05,0b00100000);//use dedicated CS pin (not shared) _adrs = 0x20;//default chip adrs when not using HAEN } writeByte(0x00,0x00);//first, set all GPIO's pin as outs (IODIR) writeByte(0x09,0b00000000);//finally, set all GPIO's out as LOW _lcd_cols = cols; //there is an implied lack of trust; the private version can't be munged up by the user. _lcd_lines = lines; _row_offsets[2] = _lcd_cols + _row_offsets[0]; //should auto-adjust for 16/20 or whatever columns now _row_offsets[3] = _lcd_cols + _row_offsets[1]; initChip(dotsize,_en1); //manage second chip if exists if (_multipleChip) { _row_offsets[2] = 0; _row_offsets[3] = 0x40; //each line gets its own little 40 char section of DDRAM--would be fine if there were a 4x32, I suppose setChip(2); initChip(dotsize,_en2);//initialize the second HD44780 chip } }
void LiquidCrystalNew_T3TWI::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) { #if defined(__TEENSY3X__) const i2c_pins temp3[2] = {I2C_PINS_18_19,I2C_PINS_16_17}; const i2c_pullup temp4[2] = {I2C_PULLUP_EXT,I2C_PULLUP_INT}; const i2c_rate temp5[11] = {I2C_RATE_100,I2C_RATE_200,I2C_RATE_300,I2C_RATE_400,I2C_RATE_600,I2C_RATE_800,I2C_RATE_1000,I2C_RATE_1200,I2C_RATE_1500,I2C_RATE_2000,I2C_RATE_2400}; Wire.begin(I2C_MASTER,0x00,temp3[_pins],temp4[_pullup],temp5[_rate]); #else #if !defined(ENERGIA) // LaunchPad, FraunchPad and StellarPad specific Wire.begin(); #if ARDUINO >= 157 Wire.setClock(400000UL); // Set I2C frequency to 400kHz #else TWBR = ((F_CPU / 400000UL) - 16) / 2; // Set I2C frequency to 400kHz //TWBR = 12; #endif #else Wire.setModule(3); Wire.begin(); #endif #endif delay(100); if (!_chipType) writeByte(0x05,0b00100000);//use dedicated cs //MCP23008 writeByte(0x00,0x00);//set as out (IODIR) writeByte(0x09,0b00000000);//write all low to GPIO _lcd_cols = cols; //there is an implied lack of trust; the private version can't be munged up by the user. _lcd_lines = lines; _row_offsets[2] = _lcd_cols + _row_offsets[0]; //should autoadjust for 16/20 or whatever columns now _row_offsets[3] = _lcd_cols + _row_offsets[1]; initChip(dotsize,_en1); //manage second chip if exists if (_multipleChip) { _row_offsets[2] = 0; _row_offsets[3] = 0x40; //each line gets its own little 40 char section of DDRAM--would be fine if there were a 4x32, I suppose setChip(2); initChip(dotsize,_en2);//initialize the second HD44780 chip } }
MAX72::MAX72(uint8_t chipSelect, uint8_t numdigits) { _chipSelect = chipSelect; _numDigits = numdigits; // Register values 0-7 for 1-8 digits pinMode(_chipSelect, OUTPUT); digitalWrite(_chipSelect, HIGH); SPI.begin(); // Start up the SPI bus // The following should only be uncommended if you really know you need to do this!!! //SPI.setClockDivider(CLOCK_DIVIDER); // Sets the SPI bus speed //SPI.setBitOrder(MSBFIRST); // Sets SPI bus bit order (this is the default, setting it for good form!) //SPI.setDataMode(SPI_MODE0); // Sets the SPI bus timing mode (this is the default, setting it for good form!) initChip(); }
void TICC1100::startListening() { try { stopListening(); openGPIO(1, true); if(!_gpioDescriptors[1] || _gpioDescriptors[1]->descriptor == -1) throw(BaseLib::Exception("Couldn't listen to rf device, because the gpio pointer is not valid: " + _settings->device)); openDevice(); if(!_fileDescriptor || _fileDescriptor->descriptor == -1) return; _stopped = false; initChip(); _firstPacket = true; _stopCallbackThread = false; _listenThread = std::thread(&TICC1100::mainThread, this); BaseLib::Threads::setThreadPriority(_bl, _listenThread.native_handle(), _settings->listenThreadPriority, _settings->listenThreadPolicy); IPhysicalInterface::startListening(); //For sniffing update packets //std::this_thread::sleep_for(std::chrono::milliseconds(1000)); //enableUpdateMode(); } catch(const std::exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(BaseLib::Exception& ex) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what()); } catch(...) { _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__); } }