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.
ACMP.h
00001 /** 00002 * LPC8xx Internal Analog Comparator library for mbed 00003 * Copyright (c) 2015 Suga 00004 * Released under the MIT License: http://mbed.org/license/mit 00005 */ 00006 /** @file 00007 * @brief LPC8xx Internal Analog Comparator library for mbed 00008 */ 00009 00010 #ifndef _ACMP_H_ 00011 #define _ACMP_H_ 00012 00013 #include "mbed.h" 00014 00015 #if !defined(TARGET_LPC81X) && !defined(TARGET_LPC82X) 00016 #error "supported for LPC8xx" 00017 #endif 00018 00019 /** ACMP class 00020 */ 00021 class ACMP { 00022 public: 00023 enum VSEL { 00024 LADDER = 0, // voltage ladder 00025 ACMP_I1 = 1, // P0.0 00026 ACMP_I2 = 2, // P0.1 00027 #if defined(TARGET_LPC81X) 00028 BANDGAP = 6, 00029 #elif defined(TARGET_LPC82X) 00030 ACMP_I3 = 3, // P0.14 00031 ACMP_I4 = 4, // P0.23 00032 BANDGAP = 5, 00033 ADC_0 = 6, 00034 #endif 00035 }; 00036 enum HYS { 00037 NONE = 0, 00038 HYS5mV = 1, 00039 HYS10mV = 2, 00040 HYS20mV = 3, 00041 }; 00042 00043 static ACMP *_acmp; 00044 00045 /** 00046 * @param ain1 Selects positive voltage input 00047 * @param ain2 Selects negative voltage input 00048 * @param hys Selects hysteresis of the comparator 00049 * @param lad Selects voltage ladder (0-31) 00050 */ 00051 ACMP (VSEL ain1, VSEL ain2, HYS hys = NONE, int lad = -1); 00052 00053 void isrAcmp (); 00054 00055 int read (); 00056 00057 void rise (void(*fptr)() = NULL) { 00058 _rise.attach(fptr); 00059 } 00060 template<typename T> 00061 void rise (T* tptr, void (T::*mptr)()) { 00062 if ((mptr != NULL) && (tptr != NULL)) { 00063 _rise.attach(tptr, mptr); 00064 } 00065 } 00066 00067 void fall (void(*fptr)() = NULL) { 00068 _fall.attach(fptr); 00069 } 00070 template<typename T> 00071 void fall (T* tptr, void (T::*mptr)()) { 00072 if ((mptr != NULL) && (tptr != NULL)) { 00073 _fall.attach(tptr, mptr); 00074 } 00075 } 00076 00077 protected: 00078 FunctionPointer _rise, _fall; 00079 00080 }; 00081 00082 #endif
Generated on Wed Jul 20 2022 22:33:09 by
1.7.2