Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: DISCO-F334C8_HiBrightLED_demo
HiBrightLED.h@0:c95c484b95a9, 2015-06-17 (annotated)
- Committer:
- bcostm
- Date:
- Wed Jun 17 06:30:59 2015 +0000
- Revision:
- 0:c95c484b95a9
- Child:
- 1:eb29c4c2a341
Initial version.
Who changed what in which revision?
| User | Revision | Line number | New 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 | #ifdef MBED_OPERATORS |
| bcostm | 0:c95c484b95a9 | 57 | /** A operator shorthand for write() |
| bcostm | 0:c95c484b95a9 | 58 | */ |
| bcostm | 0:c95c484b95a9 | 59 | HiBrightLED& operator= (float value) { |
| bcostm | 0:c95c484b95a9 | 60 | write(value); |
| bcostm | 0:c95c484b95a9 | 61 | return *this; |
| bcostm | 0:c95c484b95a9 | 62 | } |
| bcostm | 0:c95c484b95a9 | 63 | |
| bcostm | 0:c95c484b95a9 | 64 | /** An operator shorthand for read() |
| bcostm | 0:c95c484b95a9 | 65 | */ |
| bcostm | 0:c95c484b95a9 | 66 | operator float() { |
| bcostm | 0:c95c484b95a9 | 67 | return read(); |
| bcostm | 0:c95c484b95a9 | 68 | } |
| bcostm | 0:c95c484b95a9 | 69 | #endif |
| bcostm | 0:c95c484b95a9 | 70 | |
| bcostm | 0:c95c484b95a9 | 71 | private: |
| bcostm | 0:c95c484b95a9 | 72 | |
| bcostm | 0:c95c484b95a9 | 73 | float _value; // LED intensity |
| bcostm | 0:c95c484b95a9 | 74 | |
| bcostm | 0:c95c484b95a9 | 75 | uint32_t CurrentSenseTab[5]; |
| bcostm | 0:c95c484b95a9 | 76 | |
| bcostm | 0:c95c484b95a9 | 77 | DMA_HandleTypeDef DmaHandle; |
| bcostm | 0:c95c484b95a9 | 78 | HRTIM_HandleTypeDef HrtimHandle; |
| bcostm | 0:c95c484b95a9 | 79 | COMP_HandleTypeDef CompHandle; |
| bcostm | 0:c95c484b95a9 | 80 | DAC_HandleTypeDef DacHandle; |
| bcostm | 0:c95c484b95a9 | 81 | |
| bcostm | 0:c95c484b95a9 | 82 | /** |
| bcostm | 0:c95c484b95a9 | 83 | * @Brief Convert current sense value thresholds for DAC |
| bcostm | 0:c95c484b95a9 | 84 | * @param None |
| bcostm | 0:c95c484b95a9 | 85 | * @retval None |
| bcostm | 0:c95c484b95a9 | 86 | */ |
| bcostm | 0:c95c484b95a9 | 87 | void CurrentSenseTabInit(void); |
| bcostm | 0:c95c484b95a9 | 88 | |
| bcostm | 0:c95c484b95a9 | 89 | /** |
| bcostm | 0:c95c484b95a9 | 90 | * @brief DMA configuration |
| bcostm | 0:c95c484b95a9 | 91 | * @param None |
| bcostm | 0:c95c484b95a9 | 92 | * @retval None |
| bcostm | 0:c95c484b95a9 | 93 | */ |
| bcostm | 0:c95c484b95a9 | 94 | void DMA_Config(void); |
| bcostm | 0:c95c484b95a9 | 95 | |
| bcostm | 0:c95c484b95a9 | 96 | /** |
| bcostm | 0:c95c484b95a9 | 97 | * @brief DAC channel1 configuration |
| bcostm | 0:c95c484b95a9 | 98 | * @param None |
| bcostm | 0:c95c484b95a9 | 99 | * @retval None |
| bcostm | 0:c95c484b95a9 | 100 | */ |
| bcostm | 0:c95c484b95a9 | 101 | void DAC_Config(void); |
| bcostm | 0:c95c484b95a9 | 102 | |
| bcostm | 0:c95c484b95a9 | 103 | /** |
| bcostm | 0:c95c484b95a9 | 104 | * @brief Comparator configuration |
| bcostm | 0:c95c484b95a9 | 105 | * @param None |
| bcostm | 0:c95c484b95a9 | 106 | * @retval None |
| bcostm | 0:c95c484b95a9 | 107 | */ |
| bcostm | 0:c95c484b95a9 | 108 | void COMP_Config(void); |
| bcostm | 0:c95c484b95a9 | 109 | |
| bcostm | 0:c95c484b95a9 | 110 | /** |
| bcostm | 0:c95c484b95a9 | 111 | * @brief Hi-resolution Timer C configuration |
| bcostm | 0:c95c484b95a9 | 112 | * @param None |
| bcostm | 0:c95c484b95a9 | 113 | * @retval None |
| bcostm | 0:c95c484b95a9 | 114 | */ |
| bcostm | 0:c95c484b95a9 | 115 | void HRTIM_Config(void); |
| bcostm | 0:c95c484b95a9 | 116 | |
| bcostm | 0:c95c484b95a9 | 117 | /** |
| bcostm | 0:c95c484b95a9 | 118 | * @brief Set Burst Compare value |
| bcostm | 0:c95c484b95a9 | 119 | * @param BurstCompare: Burst Compare value |
| bcostm | 0:c95c484b95a9 | 120 | * @retval None |
| bcostm | 0:c95c484b95a9 | 121 | */ |
| bcostm | 0:c95c484b95a9 | 122 | void HRTIM_SetBurstCompare(uint16_t BurstCompare); |
| bcostm | 0:c95c484b95a9 | 123 | |
| bcostm | 0:c95c484b95a9 | 124 | }; |
| bcostm | 0:c95c484b95a9 | 125 | |
| bcostm | 0:c95c484b95a9 | 126 | #endif // __HIBRIGHTLED_H |