7 changed files with 142 additions and 16 deletions
@ -0,0 +1,54 @@ |
|||||
|
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
// Project: Uppsense
|
||||
|
// Name: excitation_light.cpp
|
||||
|
// Author: Maximilian Stiefel
|
||||
|
// Date: 09.08.2017
|
||||
|
//
|
||||
|
// Description:
|
||||
|
//
|
||||
|
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
//-------------------------------------Libraries------------------------------------------------------------------------------
|
||||
|
#include "excitation_light.h" |
||||
|
#include "hardware.h" |
||||
|
#include <SmingCore/SmingCore.h> |
||||
|
|
||||
|
//-------------------------------------Namespaces-----------------------------------------------------------------------------
|
||||
|
namespace rijnfel { |
||||
|
namespace light { |
||||
|
|
||||
|
//-------------------------------------Constructor----------------------------------------------------------------------------
|
||||
|
cExcitationLight::cExcitationLight(): |
||||
|
m_rectangleStatus(0), m_DAC_Rect_High(0) |
||||
|
{ |
||||
|
m_DAC = new dac::cDAC101C085(1, DAC1_ADDRESS); |
||||
|
} |
||||
|
|
||||
|
//-------------------------------------Destructor-----------------------------------------------------------------------------
|
||||
|
cExcitationLight::~cExcitationLight() |
||||
|
{ |
||||
|
delete m_DAC; |
||||
|
} |
||||
|
|
||||
|
//-------------------------------------setCurrent-----------------------------------------------------------------------------
|
||||
|
uint8_t cExcitationLight::setCurrent(uint16_t microamp) |
||||
|
{ |
||||
|
if(microamp < CURR_MAX_UAMP) |
||||
|
{ |
||||
|
m_DAC_Rect_High = R_SENSE * microamp; |
||||
|
return 1; |
||||
|
} |
||||
|
else |
||||
|
return 0; |
||||
|
} |
||||
|
|
||||
|
//-------------------------------------rectangleUpdate------------------------------------------------------------------------
|
||||
|
uint8_t cExcitationLight::rectangleUpdate() |
||||
|
{ |
||||
|
m_rectangleStatus ? m_DAC->ChangeSettings(dac::eOpMode::NORMAL, 0) : m_DAC->ChangeSettings(dac::eOpMode::NORMAL, m_DAC_Rect_High); |
||||
|
rectangle_Status ^= 0xFF; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,43 @@ |
|||||
|
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
// Project: Uppsense
|
||||
|
// Name: excitation_light.h
|
||||
|
// Author: Maximilian Stiefel
|
||||
|
// Date: 09.08.2017
|
||||
|
//
|
||||
|
// Description:
|
||||
|
//
|
||||
|
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
#ifndef APP_EXCITATION_LIGHT_H_ |
||||
|
#define APP_EXCITATION_LIGHT_H_ |
||||
|
|
||||
|
//-------------------------------------Libraries------------------------------------------------------------------------------
|
||||
|
#include <stdint.h> |
||||
|
#include "dac101c085.h" |
||||
|
#include "hardware.h" |
||||
|
|
||||
|
//-------------------------------------Defines--------------------------------------------------------------------------------
|
||||
|
|
||||
|
//-------------------------------------Namespaces-----------------------------------------------------------------------------
|
||||
|
namespace rijnfel { |
||||
|
namespace light { |
||||
|
|
||||
|
//-------------------------------------Enums----------------------------------------------------------------------------------
|
||||
|
|
||||
|
//-------------------------------------cExcitationLight-----------------------------------------------------------------------
|
||||
|
class cExcitationLight |
||||
|
{ |
||||
|
public: |
||||
|
cExcitationLight(); // Constructor
|
||||
|
~cExcitationLight(); // Destructor
|
||||
|
uint8_t setCurrent(uint16_t microamp); |
||||
|
uint8_t rectangleUpdate(); |
||||
|
private: |
||||
|
dac::cDAC101C085 *m_DAC; |
||||
|
uint8_t m_rectangleStatus; |
||||
|
uint16_t m_DAC_Rect_High; |
||||
|
}; |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
#endif /* APP_EXCITATION_LIGHT_H_ */ |
@ -0,0 +1,21 @@ |
|||||
|
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
// Project: Uppsense
|
||||
|
// Name: hardware.h
|
||||
|
// Author: Maximilian Stiefel
|
||||
|
// Date: 09.08.2017
|
||||
|
//
|
||||
|
// Description:
|
||||
|
//
|
||||
|
//----------------------------------------------------------------------------------------------------------------------------
|
||||
|
|
||||
|
#ifndef APP_HARDWARE_H_ |
||||
|
#define APP_HARDWARE_H_ |
||||
|
|
||||
|
//-------------------------------------I2C ADRESSES---------------------------------------------------------------------------
|
||||
|
static const uint8_t ADC_ADDRESS = 0x48; |
||||
|
static const uint8_t DAC1_ADDRESS = 0xC; |
||||
|
|
||||
|
#define R_SENSE (uint8_t) 100 // 100 Ohm sensing resistor
|
||||
|
#define CURR_MAX_UAMP 10000 // 10 mA max.
|
||||
|
|
||||
|
#endif /* APP_HARDWARE_H_ */ |
Loading…
Reference in new issue