Beispiel #1
0
int i2c_close() {
    MUTEX_TAKE(i2c_mutex, -1); 
    if(i2c_open_count && --i2c_open_count == 0) {
        pPMC->PMC_PCDR = ( (uint32_t) 1 << AT91C_ID_TWI );
    }
    MUTEX_GIVE(i2c_mutex); 
    return 0;
}
Beispiel #2
0
int i2c_open() {
    MUTEX_TAKE(i2c_mutex, -1); 
    if(!i2c_open_count++) {
        pPMC->PMC_PCER = ( (uint32_t) 1 << AT91C_ID_TWI );
    }
    MUTEX_GIVE(i2c_mutex); 
    return 0;
}
Beispiel #3
0
int i2cMasterRead(uint8_t i2c_addr, uint8_t intaddr_size, uint32_t int_addr, uint8_t *data) {
    MUTEX_TAKE(i2c_mutex, -1); 
    pm_lock();
    i2cMasterConf(i2c_addr, intaddr_size, int_addr, I2CMASTER_READ);
    int rc = i2cReadByte(data);
    pm_unlock();
    MUTEX_GIVE(i2c_mutex); 
    return rc;
}
Beispiel #4
0
int i2cMasterWrite(uint8_t i2c_addr, uint8_t intaddr_size, uint32_t int_addr, uint8_t data) {
    MUTEX_TAKE(i2c_mutex, -1); 
    pm_lock();
    i2cMasterConf(i2c_addr, intaddr_size, int_addr, I2CMASTER_WRITE);
    int rc = i2cWriteByte(data);
    pm_unlock();
    MUTEX_GIVE(i2c_mutex); 
    return rc;
}
Beispiel #5
0
static inline void
MUTEX_RELEASE(kmutex_t *mtx)
{
	uintptr_t newown;

	MUTEX_GIVE(mtx);
	newown = 0;
	MUTEX_INHERITDEBUG(newown, mtx->mtx_owner);
	mtx->mtx_owner = newown;
}
Beispiel #6
0
int i2c_unlock() {
    MUTEX_GIVE(i2c_mutex); 
}