62c088256f
added the RGB sensor isl29125 added WIFI
217 lines
6.5 KiB
C++
217 lines
6.5 KiB
C++
// --------------------------------------------------------------------------------------------------------------------
|
|
/// \file isl29125.h
|
|
/// \brief File description
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
//
|
|
// vbchaos software design
|
|
//
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
/// $Revision: $
|
|
/// $Author: $
|
|
/// $Date: $
|
|
// (c) 2023 vbchaos
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
#ifndef MAIN_PLATFORM_INC_ISL29125_H_
|
|
#define MAIN_PLATFORM_INC_ISL29125_H_
|
|
|
|
/**
|
|
* isl29125 implementation
|
|
* \defgroup isl29125
|
|
* \brief {group_description}
|
|
* \addtogroup {Layer}
|
|
*
|
|
* Detailed description
|
|
* @{
|
|
*/
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
// Include files
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
// CompilerIncludes
|
|
// All include files that are provided by the compiler directly
|
|
#include <stdint.h>
|
|
|
|
|
|
// ProjectIncludes
|
|
// All include files that are provided by the project
|
|
#include "ISerialBus.h"
|
|
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
// Constant and macro definitions
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
// Type definitions.
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
// Function declarations
|
|
// --------------------------------------------------------------------------------------------------------------------
|
|
|
|
class isl29125
|
|
{
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
// Public Section
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
public:
|
|
|
|
struct rgb_t
|
|
{
|
|
uint16_t red;
|
|
uint16_t green;
|
|
uint16_t blue;
|
|
} RGB_t;
|
|
|
|
typedef enum
|
|
{
|
|
POWER_DOWN = 0,
|
|
GREEN = 1,
|
|
RED = 2,
|
|
BLUE = 3,
|
|
STANDBY = 4,
|
|
RGB = 5,
|
|
GREEN_RED = 6,
|
|
GREEN_BLUE = 7
|
|
} Mode_t;
|
|
|
|
typedef enum
|
|
{
|
|
LOW = 0,
|
|
HIGH = 1
|
|
} Range_t;
|
|
|
|
typedef enum
|
|
{
|
|
RES_12BIT = 0,
|
|
RES_16BIT = 1
|
|
} Resolution_t;
|
|
|
|
const uint8_t deviceID = 0x7D;
|
|
|
|
// Class Constructor
|
|
isl29125(uint8_t slaveAddress, ISerialBus<uint8_t>& serialPort);
|
|
FunctionStatus initialize(void);
|
|
|
|
FunctionStatus setMode(Mode_t mode);
|
|
FunctionStatus setRange(Range_t range);
|
|
FunctionStatus setResolution(Resolution_t resolutionß);
|
|
|
|
FunctionStatus getRGB(struct rgb_t* rgb);
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
// Protected Section
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
protected:
|
|
|
|
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
// Private Section
|
|
// -----------------------------------------------------------------------------------------------------------------
|
|
private:
|
|
|
|
struct __attribute__ ((packed)) memorymap
|
|
{
|
|
uint8_t device_id;
|
|
struct
|
|
{
|
|
uint8_t mode :3;
|
|
uint8_t range :1;
|
|
uint8_t bits :1;
|
|
uint8_t sync :1;
|
|
uint8_t RESERVERED :2;
|
|
} configuration1;
|
|
struct
|
|
{
|
|
uint8_t alscc :6;
|
|
uint8_t RESERVED :1;
|
|
uint8_t ircom :1;
|
|
} configuration2;
|
|
struct
|
|
{
|
|
uint8_t intsel :2;
|
|
uint8_t prst :2;
|
|
uint8_t conven :1;
|
|
uint8_t RESERVED :3;
|
|
} configuration3;
|
|
struct
|
|
{
|
|
uint8_t lowByte;
|
|
uint8_t highByte;
|
|
} lowThreshold;
|
|
struct
|
|
{
|
|
uint8_t lowByte;
|
|
uint8_t highByte;
|
|
} highThreshold;
|
|
struct
|
|
{
|
|
uint8_t RESERVED1 :2;
|
|
uint8_t grbcf :2;
|
|
uint8_t RESERVED2 :1;
|
|
uint8_t boutf :1;
|
|
uint8_t convenf :1;
|
|
uint8_t rgbthf :1;
|
|
} statusFlags;
|
|
union
|
|
{
|
|
uint16_t word;
|
|
struct
|
|
{
|
|
uint8_t lowByte;
|
|
uint8_t highByte;
|
|
};
|
|
} greenData;
|
|
union
|
|
{
|
|
uint16_t word;
|
|
struct
|
|
{
|
|
uint8_t lowByte;
|
|
uint8_t highByte;
|
|
};
|
|
} redData;
|
|
union
|
|
{
|
|
uint16_t word;
|
|
struct
|
|
{
|
|
uint8_t lowByte;
|
|
uint8_t highByte;
|
|
};
|
|
} blueData;
|
|
};
|
|
|
|
struct memorymap memorymap;
|
|
|
|
uint8_t slaveAddress;
|
|
ISerialBus<uint8_t>& bus;
|
|
bool initialized;
|
|
|
|
// Reads the device ID directly into the memory map
|
|
FunctionStatus getDeviceID(void);
|
|
// Reads all configuration registers into the memory map
|
|
FunctionStatus getConfiguration(void);
|
|
// Reads all Threshold registers into the memory map
|
|
FunctionStatus getTheshold(void);
|
|
// Reads the status register into the memory map
|
|
FunctionStatus getStatusFlags(void);
|
|
// Reads the RGB data registers into the memory map
|
|
FunctionStatus getRGBRegisters(void);
|
|
// Read the full memory map from device into the local memory map, which creates a perfect memory copy
|
|
FunctionStatus getCompleteRegisterMap(void);
|
|
|
|
};
|
|
|
|
/** @} */
|
|
|
|
|
|
#endif /* MAIN_PLATFORM_INC_ISL29125_H_ */
|