void SPI::format(int bits, int mode, spi_bitorder_t order) { _bits = bits; _mode = mode; _order = order; SPI::_owner = NULL; // Not that elegant, but works. rmeyer aquire(); }
void SPI::start_transfer(const Buffer& tx, const Buffer& rx, const event_callback_t& callback, int event) { aquire(); _current_transaction.callback = callback; _current_transaction.tx_buffer = tx; _current_transaction.rx_buffer = rx; _irq.callback(&SPI::irq_handler_asynch); spi_master_transfer(&_spi, tx.buf, tx.length, rx.buf, rx.length, _irq.entry(), event , _usage); }
// read - Master Reciever Mode int I2C::read(int address, char* data, int length, bool repeated) { aquire(); int stop = (repeated) ? 0 : 1; int retval = i2c_read(&_i2c, address, data, length, stop); return retval; }
// write - Master Transmitter Mode int I2C::write(int address, const char* data, int length, bool repeated) { lock(); aquire(); int stop = (repeated) ? 0 : 1; int written = i2c_write(&_i2c, address, data, length, stop); unlock(); return length != written; }
// read - Master Reciever Mode int I2C::read(int address, char* data, int length, bool repeated) { lock(); aquire(); int stop = (repeated) ? 0 : 1; int read = i2c_read(&_i2c, address, data, length, stop); unlock(); return length != read; }
static void* do_liblock_execute_operation(mwait)(liblock_lock_t* lock, void* (*pending)(void*), void* val) { struct liblock_impl* impl = lock->impl; void* res; aquire(impl); res = pending(val); release(impl); return res; }
void Statusbar::print(int line, std::string str) { std::stringstream ss; ss << TERM_SAVE_CURSOR << "\033["; ss << startLine; ss << ";1H" << str << TERM_LOAD_CURSOR; release(); printf("%s\n", ss.str().c_str()); aquire(); }
int I2C::transfer(int address, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, const event_callback_t& callback, int event, bool repeated) { lock(); if (i2c_active(&_i2c)) { unlock(); return -1; // transaction ongoing } aquire(); _callback = callback; int stop = (repeated) ? 0 : 1; _irq.callback(&I2C::irq_handler_asynch); i2c_transfer_asynch(&_i2c, (void *)tx_buffer, tx_length, (void *)rx_buffer, rx_length, address, stop, _irq.entry(), event, _usage); unlock(); return 0; }
static int cond_timedwait(liblock_cond_t* cond, liblock_lock_t* lock, const struct timespec* ts) { fatal("implement me"); struct liblock_impl* impl = lock->impl; int res; pthread_mutex_lock(&impl->posix_lock); release(impl); if(ts) res = pthread_cond_timedwait(&cond->impl.posix_cond, &impl->posix_lock, ts); else res = pthread_cond_wait(&cond->impl.posix_cond, &impl->posix_lock); pthread_mutex_unlock(&impl->posix_lock); aquire(impl); return res; }
std::shared_ptr<PWMImpl> PWMFactory::createPWM(PWM_CHANNEL po) { std::lock_guard<std::mutex> l(dataMutex); if (pwmMap.find(po) != pwmMap.end()) { PC_EXCEPTION(PinLockedException, "Selected PWM pin already " "locked."); } auto gpioInstance = GPIOManager::getInstance(); if (!gpioInstance) { PC_EXCEPTION(InternalErrorException, "Instance of GPIO manager " "object is NULL."); } if (po < PWM_CHANNEL::PWM_0 || po >= PWM_CHANNEL::PWM_MAX) { PC_EXCEPTION(IncorrectParamException, "Invalid PWM pin index."); } gpioInstance->aquire(contactMap.at(po)); std::shared_ptr<PWMImpl> sp; try { sp = std::shared_ptr<PWMImpl>(new PWMImpl(po)); } catch (Exception& e) { gpioInstance->release(contactMap.at(po)); throw e; } pwmMap[po] = sp; return sp; }
static void do_liblock_relock_in_cs(mwait)(liblock_lock_t* lock) { struct liblock_impl* impl = lock->impl; aquire(impl); }
void Material::aquire(World *world) { // Remove item from world database WorldDB *db = world->get_db(); aquire(db); }
int64_t increment_and_get( uint64_t inc ) { auto tmp = aquire() + inc; store( tmp ); return tmp; }
void CDeviceGarminBulk::uploadWpts(const QList<CWpt*>& wpts) { //QMessageBox::information(0,tr("Error..."), tr("Garmin Mass Storage: Upload waypoints is not implemented."),QMessageBox::Abort,QMessageBox::Abort); QDir dir; if(!aquire(dir)) { return; } createDayPath(dir, tr("waypoints")); QStringList keys; foreach(CWpt* wpt, wpts) { if(wpt == 0) { continue; } keys << wpt->getKey(); if(!wpt->images.isEmpty()) { if(wpt->isGeoCache() && !pathSpoilers.isEmpty()) { int cnt = 1; QString name = wpt->getName(); quint32 size = name.size(); QString path = QString("%1/%2/%3").arg(name.at(size-1)).arg(name.at(size -2)).arg(name); dir.cd(pathSpoilers); dir.mkpath(path + "/Spoilers"); dir.cd(path); foreach(const CWpt::image_t& img, wpt->images) { QString fn = img.info; if(fn.isEmpty()) { fn = QString("pix%1.jpg").arg(cnt++); } if(!fn.endsWith("jpg")) { fn += ".jpg"; } if(fn.contains("Spoiler")) { fn = "Spoilers/" + fn; } img.pixmap.save(dir.absoluteFilePath(fn)); } } else { if(!pathPictures.isEmpty()) { dir.cd(pathPictures); CWpt::image_t img = wpt->images.first(); QString fn = img.filename; if(fn.isEmpty()) { fn = wpt->getName() + ".jpg"; } img.pixmap.save(dir.absoluteFilePath(fn)); wpt->link = pathPictures + "/" + fn; } } dir.cd(pathRoot); }
Statusbar::Statusbar(int height) : height(height) , startLine(0) { aquire(); }
void SPI::format(int bits, int mode) { _bits = bits; _mode = mode; SPI::_owner = NULL; // Not that elegant, but works. rmeyer aquire(); }
int SPI::write(int value) { aquire(); return spi_master_write(&_spi, value); }
void SPI::frequency(int hz) { _hz = hz; SPI::_owner = NULL; // Not that elegant, but works. rmeyer aquire(); }