static int LM75_init(LM75_Object *self, PyObject *args, PyObject *kwds) { int address; const char *i2c_device; static char *kwlist[] = {"address", "i2c_devcie", NULL}; if(!PyArg_ParseTupleAndKeywords(args, kwds, "is", kwlist, &address, &i2c_device)) return -1; if(i2c_device) { self->lm75 = lm75_init(address, i2c_device); if(self->lm75 == NULL) { PyErr_SetString(PyExc_RuntimeError, "Cannot initialize sensor. Run program as root and check i2c device / address."); return -1; } } return 0; }
void matemat_init() { DDR_CONFIG_OUT(MATEMAT_COOLER); PIN_CLEAR(MATEMAT_COOLER); DDRC &= ~((1<<PC4)|(1<<PC3)); DDRC |= ((1<<PC5)|(1<<PC6)); PORTC |= (1<<PC4)|(1<<PC3); PORTC &= ~((1<<PC5)|(1<<PC6)); i2c_init(); lm75_init(); matemat_setupdisp(); usart_init(); // usart(UCSR,B) &= ~_BV(usart(RXCIE)); matemat_global.mode = MODE_IDLE; matemat_global.temps[TEMP_START] = temp(TEMP_START_VAL); matemat_global.temps[TEMP_STOP] = temp(TEMP_STOP_VAL); TCCR0B = 1<<CS01; //div by 8 TIMSK0 |= 1<<TOIE0; }