Compile SD library
Dependencies: SDFileSystem USBDevice max32630fthr
Fork of MAX30001-MAX32630FTHR-ECG-EVKIT by
HspLed.h
00001 /******************************************************************************* 00002 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a 00005 * copy of this software and associated documentation files (the "Software"), 00006 * to deal in the Software without restriction, including without limitation 00007 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 00008 * and/or sell copies of the Software, and to permit persons to whom the 00009 * Software is furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included 00012 * in all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 00015 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00016 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00017 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES 00018 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00019 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00020 * OTHER DEALINGS IN THE SOFTWARE. 00021 * 00022 * Except as contained in this notice, the name of Maxim Integrated 00023 * Products, Inc. shall not be used except as stated in the Maxim Integrated 00024 * Products, Inc. Branding Policy. 00025 * 00026 * The mere transfer of this software does not imply any licenses 00027 * of trade secrets, proprietary technology, copyrights, patents, 00028 * trademarks, maskwork rights, or any other form of intellectual 00029 * property whatsoever. Maxim Integrated Products, Inc. retains all 00030 * ownership rights. 00031 ******************************************************************************* 00032 */ 00033 #ifndef _LED_H_ 00034 #define _LED_H_ 00035 00036 #include "mbed.h" 00037 00038 /** 00039 * Driver for the HSP Led, supports different blink rates and patterns 00040 * 00041 * @code 00042 * #include <stdio.h> 00043 * #include "mbed.h" 00044 * #include "xxx.h" 00045 * 00046 * I2C i2c(I2C_SDA, I2C_SCL); 00047 * xxx xxx(&i2c); 00048 * 00049 * int main(void) { 00050 * printf("Initialized xxx\n"); 00051 * while(1) { 00052 * if (xxx.init() != 0) { 00053 * printf("Error communicating with xxx\n"); 00054 * } else { 00055 * printf("Initialized xxx\n"); 00056 * break; 00057 * } 00058 * wait(1); 00059 * } 00060 * 00061 * while(1) { 00062 * printf(""); 00063 * wait(1); 00064 * } 00065 * } 00066 * @endcode 00067 */ 00068 00069 class HspLed { 00070 public: 00071 static const int LED_ON = 0; 00072 static const int LED_OFF = 1; 00073 00074 /// define all of the modes the LED can support 00075 typedef enum eMode { 00076 eLedOn, 00077 eLedOff, 00078 eLedPeriod, 00079 eLedPattern 00080 } eMode; 00081 /// define the values that turn the LED on or off at the pin 00082 #define HSP_LED_ON 0 00083 #define HSP_LED_OFF 1 00084 00085 /* 00086 * @brief Constructor where you specify the LED pin name 00087 */ 00088 HspLed(PinName ledPin); 00089 00090 /** 00091 * Blink the HSP LED at a set time interval 00092 * @param mSeconds Number of seconds to set the timer interval 00093 */ 00094 void blink(uint32_t mSeconds); 00095 00096 /** 00097 * @brief Start rotating the LED through a 32-bit pattern at a mS rate specified 00098 * @param pattern 32-bit pattern to rotate through 00099 * @param mSeconds the amount of time to take per bit in the pattern 00100 */ 00101 void pattern(uint32_t pattern, uint32_t mSeconds); 00102 00103 /** 00104 * @brief Turn the LED on 00105 */ 00106 void on(void); 00107 00108 /** 00109 * @brief Turn the LED off 00110 */ 00111 void off(void); 00112 00113 /** 00114 * @brief Update the LED 00115 */ 00116 void service(void); 00117 00118 private: 00119 00120 /** 00121 * Set the mode of the LED, the mode include blinking at a set rate or blinking 00122 * according to a pattern 00123 * @param mode Mode to set the LED to 00124 */ 00125 void setMode(eMode state); 00126 00127 /** 00128 * Toggle the state of the LED 00129 */ 00130 void toggle(void); 00131 00132 /** 00133 * Start the LED blinking or rotating through a pattern 00134 */ 00135 void start(void); 00136 00137 /** 00138 * Stop blinking or rotating through a pattern 00139 */ 00140 void stop(void); 00141 00142 /** 00143 * Write the LED pin to a state 00144 * @param state A one or zero value to write to the LED pin 00145 */ 00146 void state(int state); 00147 00148 /* 00149 * @brief Single step through the pattern and output to the LED 00150 */ 00151 void patternToLed(void); 00152 00153 /// timer interval in mS 00154 float timerInterval; 00155 /// last timer interval set to... used to prevent resetting the timer to the same value 00156 float timerIntervalLast; 00157 /// local state of the pattern to rotate through 00158 uint32_t bitPattern; 00159 /// current mode of the LED 00160 eMode mode; 00161 /// the LED digital output 00162 DigitalOut redLed; 00163 /// Timer service used to update the LED 00164 Ticker ticker; 00165 /// Flag to indicate if the timer has been started 00166 bool isStarted; 00167 }; 00168 00169 #endif /* _LED_H_ */ 00170
Generated on Mon Jul 18 2022 20:23:41 by 1.7.2