ST / HiBrightLED

Dependents:   DISCO-F334C8_HiBrightLED_demo

Committer:
arostm
Date:
Thu Jun 08 14:26:33 2017 +0000
Revision:
1:eb29c4c2a341
Parent:
0:c95c484b95a9
Remove if else for operator (=) definition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:c95c484b95a9 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
bcostm 0:c95c484b95a9 2 *
bcostm 0:c95c484b95a9 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bcostm 0:c95c484b95a9 4 * and associated documentation files (the "Software"), to deal in the Software without
bcostm 0:c95c484b95a9 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
bcostm 0:c95c484b95a9 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
bcostm 0:c95c484b95a9 7 * Software is furnished to do so, subject to the following conditions:
bcostm 0:c95c484b95a9 8 *
bcostm 0:c95c484b95a9 9 * The above copyright notice and this permission notice shall be included in all copies or
bcostm 0:c95c484b95a9 10 * substantial portions of the Software.
bcostm 0:c95c484b95a9 11 *
bcostm 0:c95c484b95a9 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bcostm 0:c95c484b95a9 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bcostm 0:c95c484b95a9 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bcostm 0:c95c484b95a9 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bcostm 0:c95c484b95a9 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bcostm 0:c95c484b95a9 17 */
bcostm 0:c95c484b95a9 18
bcostm 0:c95c484b95a9 19 #ifndef __HIBRIGHTLED_H
bcostm 0:c95c484b95a9 20 #define __HIBRIGHTLED_H
bcostm 0:c95c484b95a9 21
bcostm 0:c95c484b95a9 22 #include "mbed.h"
bcostm 0:c95c484b95a9 23
bcostm 0:c95c484b95a9 24 /**
bcostm 0:c95c484b95a9 25 * High Brightness LED
bcostm 0:c95c484b95a9 26 */
bcostm 0:c95c484b95a9 27 class HiBrightLED
bcostm 0:c95c484b95a9 28 {
bcostm 0:c95c484b95a9 29
bcostm 0:c95c484b95a9 30 public:
bcostm 0:c95c484b95a9 31
bcostm 0:c95c484b95a9 32 /**
bcostm 0:c95c484b95a9 33 * Constructor
bcostm 0:c95c484b95a9 34 */
bcostm 0:c95c484b95a9 35 HiBrightLED();
bcostm 0:c95c484b95a9 36
bcostm 0:c95c484b95a9 37 /**
bcostm 0:c95c484b95a9 38 * Destructor
bcostm 0:c95c484b95a9 39 */
bcostm 0:c95c484b95a9 40 ~HiBrightLED();
bcostm 0:c95c484b95a9 41
bcostm 0:c95c484b95a9 42 /**
bcostm 0:c95c484b95a9 43 * @brief Set the LED intensity
bcostm 0:c95c484b95a9 44 * @param value Intensity (0.0 to 1.0)
bcostm 0:c95c484b95a9 45 * @retval None
bcostm 0:c95c484b95a9 46 */
bcostm 0:c95c484b95a9 47 void write(float value);
bcostm 0:c95c484b95a9 48
bcostm 0:c95c484b95a9 49 /**
bcostm 0:c95c484b95a9 50 * @brief Return the LED intensity
bcostm 0:c95c484b95a9 51 * @param None
bcostm 0:c95c484b95a9 52 * @retval Intensity (0.0 to 1.0)
bcostm 0:c95c484b95a9 53 */
bcostm 0:c95c484b95a9 54 float read();
bcostm 0:c95c484b95a9 55
bcostm 0:c95c484b95a9 56 /** A operator shorthand for write()
bcostm 0:c95c484b95a9 57 */
bcostm 0:c95c484b95a9 58 HiBrightLED& operator= (float value) {
bcostm 0:c95c484b95a9 59 write(value);
bcostm 0:c95c484b95a9 60 return *this;
bcostm 0:c95c484b95a9 61 }
bcostm 0:c95c484b95a9 62
bcostm 0:c95c484b95a9 63 /** An operator shorthand for read()
bcostm 0:c95c484b95a9 64 */
bcostm 0:c95c484b95a9 65 operator float() {
bcostm 0:c95c484b95a9 66 return read();
bcostm 0:c95c484b95a9 67 }
bcostm 0:c95c484b95a9 68
bcostm 0:c95c484b95a9 69 private:
bcostm 0:c95c484b95a9 70
bcostm 0:c95c484b95a9 71 float _value; // LED intensity
bcostm 0:c95c484b95a9 72
bcostm 0:c95c484b95a9 73 uint32_t CurrentSenseTab[5];
bcostm 0:c95c484b95a9 74
bcostm 0:c95c484b95a9 75 DMA_HandleTypeDef DmaHandle;
bcostm 0:c95c484b95a9 76 HRTIM_HandleTypeDef HrtimHandle;
bcostm 0:c95c484b95a9 77 COMP_HandleTypeDef CompHandle;
bcostm 0:c95c484b95a9 78 DAC_HandleTypeDef DacHandle;
bcostm 0:c95c484b95a9 79
bcostm 0:c95c484b95a9 80 /**
bcostm 0:c95c484b95a9 81 * @Brief Convert current sense value thresholds for DAC
bcostm 0:c95c484b95a9 82 * @param None
bcostm 0:c95c484b95a9 83 * @retval None
bcostm 0:c95c484b95a9 84 */
bcostm 0:c95c484b95a9 85 void CurrentSenseTabInit(void);
bcostm 0:c95c484b95a9 86
bcostm 0:c95c484b95a9 87 /**
bcostm 0:c95c484b95a9 88 * @brief DMA configuration
bcostm 0:c95c484b95a9 89 * @param None
bcostm 0:c95c484b95a9 90 * @retval None
bcostm 0:c95c484b95a9 91 */
bcostm 0:c95c484b95a9 92 void DMA_Config(void);
bcostm 0:c95c484b95a9 93
bcostm 0:c95c484b95a9 94 /**
bcostm 0:c95c484b95a9 95 * @brief DAC channel1 configuration
bcostm 0:c95c484b95a9 96 * @param None
bcostm 0:c95c484b95a9 97 * @retval None
bcostm 0:c95c484b95a9 98 */
bcostm 0:c95c484b95a9 99 void DAC_Config(void);
bcostm 0:c95c484b95a9 100
bcostm 0:c95c484b95a9 101 /**
bcostm 0:c95c484b95a9 102 * @brief Comparator configuration
bcostm 0:c95c484b95a9 103 * @param None
bcostm 0:c95c484b95a9 104 * @retval None
bcostm 0:c95c484b95a9 105 */
bcostm 0:c95c484b95a9 106 void COMP_Config(void);
bcostm 0:c95c484b95a9 107
bcostm 0:c95c484b95a9 108 /**
bcostm 0:c95c484b95a9 109 * @brief Hi-resolution Timer C configuration
bcostm 0:c95c484b95a9 110 * @param None
bcostm 0:c95c484b95a9 111 * @retval None
bcostm 0:c95c484b95a9 112 */
bcostm 0:c95c484b95a9 113 void HRTIM_Config(void);
bcostm 0:c95c484b95a9 114
bcostm 0:c95c484b95a9 115 /**
bcostm 0:c95c484b95a9 116 * @brief Set Burst Compare value
bcostm 0:c95c484b95a9 117 * @param BurstCompare: Burst Compare value
bcostm 0:c95c484b95a9 118 * @retval None
bcostm 0:c95c484b95a9 119 */
bcostm 0:c95c484b95a9 120 void HRTIM_SetBurstCompare(uint16_t BurstCompare);
bcostm 0:c95c484b95a9 121
bcostm 0:c95c484b95a9 122 };
bcostm 0:c95c484b95a9 123
bcostm 0:c95c484b95a9 124 #endif // __HIBRIGHTLED_H