예제 #1
0
파일: SPI.cpp 프로젝트: sg-/mbed-drivers
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();
}
예제 #2
0
파일: SPI.cpp 프로젝트: sg-/mbed-drivers
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);
}
예제 #3
0
파일: I2C.cpp 프로젝트: 3eggert/mbed
// 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;
}
예제 #4
0
파일: I2C.cpp 프로젝트: NXPmicro/mbed
// 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;
}
예제 #5
0
파일: I2C.cpp 프로젝트: NXPmicro/mbed
// 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;
}
예제 #6
0
파일: mwait.c 프로젝트: SANL-2015/SANL-2015
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;
}
예제 #7
0
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();
}
예제 #8
0
파일: I2C.cpp 프로젝트: NXPmicro/mbed
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;
}
예제 #9
0
파일: mwait.c 프로젝트: SANL-2015/SANL-2015
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;
}
예제 #10
0
    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;
    }
예제 #11
0
파일: mwait.c 프로젝트: SANL-2015/SANL-2015
static void do_liblock_relock_in_cs(mwait)(liblock_lock_t* lock) {
	struct liblock_impl* impl = lock->impl;
	aquire(impl);
}
예제 #12
0
void Material::aquire(World *world)
{
    // Remove item from world database
    WorldDB *db = world->get_db();
    aquire(db);
}
예제 #13
0
 int64_t increment_and_get( uint64_t inc ) 
 { 
     auto tmp = aquire() + inc;
     store( tmp );
     return tmp;
 }
예제 #14
0
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);
        }
예제 #15
0
Statusbar::Statusbar(int height)
	: height(height)
	, startLine(0)
{
	aquire();
}
예제 #16
0
파일: SPI.cpp 프로젝트: ElAbbassi/mbed
void SPI::format(int bits, int mode) {
    _bits = bits;
    _mode = mode;
    SPI::_owner = NULL; // Not that elegant, but works. rmeyer
    aquire();
}
예제 #17
0
파일: SPI.cpp 프로젝트: ElAbbassi/mbed
int SPI::write(int value) {
    aquire();
    return spi_master_write(&_spi, value);
}
예제 #18
0
파일: SPI.cpp 프로젝트: ElAbbassi/mbed
void SPI::frequency(int hz) {
    _hz = hz;
    SPI::_owner = NULL; // Not that elegant, but works. rmeyer
    aquire();
}