Przejdź do głównej zawartości

Posty

Wyświetlanie postów z maj, 2017

OPT3001 AVR C LIB - OPT3001.c

/* * OPT3001.c * * Created on: 30 Jan 2017 * Author: metallmaniac82 */ #include #include #include #include #include "OPT3001.h" #include "I2CHARDWARE.h" void OPT3001_setReg(uint8_t _OPT3001_Addr, _OPT3001_Register reg, uint16_t value){ I2CBuff[0] = (value >> 8); I2CBuff[1] = value; I2C_WriteBuff(_OPT3001_Addr, reg, I2CBUFFSIZE, I2CBuff); } uint16_t OPT3001_getReg(uint8_t _OPT3001_Addr, _OPT3001_Register reg){ uint16_t result = 0x0000; I2C_ReadBuff(_OPT3001_Addr,reg, I2CBUFFSIZE, I2CBuff ); result |= I2CBuff[0] > 12; }else if (range

OPT3001 AVR C LIB - OPT3001.h

/* * OPT3001.h * * Created on: 25 Jan 2017 * Author: metallmaniac82 */ #ifndef OPT3001_H_ #define OPT3001_H_ #define _OPT3001_ADDR0 0x44 #define _OPT3001_ADDR1 0x45 #define _OPT3001_ADDR2 0x46 #define _OPT3001_ADDR3 0x47 #define _ENABLE 0x01 #define _DISABLE 0x00 volatile uint32_t LUX; volatile uint16_t range; volatile static uint16_t exponentValueTable [] = {1,2,4,8,16,32,64,128,256,512,1024,2048}; typedef enum { SHUTDOWN, SINGLE_SHOT, CONTINOUS0, CONTINOUS1 } _Conversion_Modes; typedef enum { CONVERSION_TIME_100, CONVERSION_TIME_800 } _Conversion_Time; typedef enum { RANGE_4095, RANGE_8190, RANGE_16380, RANGE_32760, RANGE_65520, RANGE_131040, RANGE_262080, RANGE_524160, RANGE_1048320, RANGE_2096640, RANGE_4193280, RANGE_8386560, RANGE_AUTO } _FullScaleModeRange; typedef enum { RESULT = 0x00, CONFIGURATION, LOWLIMIT, HIGHLIMIT, MANUFACTURERID = 0x7F, DEVICEID } _OPT3001_Register; typedef volatile union{ struct{ uint16_t mantisa:1...