Fork of mbed_official/TSI, giving access to raw values
Dependents: PiezoClick USB_Handson Midiudelator XtrinsicSensorEVK ... more
Fork of TSI by
Revision 4:4dc2f5a3a731, committed 2013-06-28
- Comitter:
- vsluiter
- Date:
- Fri Jun 28 13:59:29 2013 +0000
- Parent:
- 3:1a60ef257879
- Commit message:
- Working program, with modified TSI library;
Changed in this revision
TSISensor.cpp | Show annotated file Show diff for this revision Revisions of this file |
TSISensor.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1a60ef257879 -r 4dc2f5a3a731 TSISensor.cpp --- a/TSISensor.cpp Thu May 09 09:24:34 2013 +0000 +++ b/TSISensor.cpp Fri Jun 28 13:59:29 2013 +0000 @@ -26,7 +26,7 @@ #define NO_TOUCH 0 #define SLIDER_LENGTH 40 //LENGTH in mm -#define TOTAL_ELECTRODE 2 +#define TOTAL_ELECTRODE 3 #define TSI0a 0 #define TSI1 1 @@ -123,6 +123,29 @@ selfCalibration(); } +void TSISensor::TSISensor_reset(void) { + SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK; + SIM->SCGC5 |= SIM_SCGC5_TSI_MASK; + + TSI0->GENCS |= (TSI_GENCS_ESOR_MASK + | TSI_GENCS_MODE(0) + | TSI_GENCS_REFCHRG(4) + | TSI_GENCS_DVOLT(0) + | TSI_GENCS_EXTCHRG(7) + | TSI_GENCS_PS(4) + | TSI_GENCS_NSCN(11) + | TSI_GENCS_TSIIEN_MASK + | TSI_GENCS_STPE_MASK + ); + + TSI0->GENCS |= TSI_GENCS_TSIEN_MASK; + + //NVIC_SetVector(TSI0_IRQn, (uint32_t)&tsi_irq); + //NVIC_EnableIRQ(TSI0_IRQn); + + selfCalibration(); +} + void TSISensor::selfCalibration(void) { unsigned char cnt; @@ -194,6 +217,11 @@ return AbsoluteDistancePosition; } +uint16_t TSISensor::readValue(uint8_t index) +{ + return gu16TSICount[index]; +} + static void changeElectrode(void) { int16_t u16temp_delta;
diff -r 1a60ef257879 -r 4dc2f5a3a731 TSISensor.h --- a/TSISensor.h Thu May 09 09:24:34 2013 +0000 +++ b/TSISensor.h Fri Jun 28 13:59:29 2013 +0000 @@ -62,6 +62,8 @@ * @returns distance in mm. The value is between [0 ... 40] */ uint8_t readDistance(); + uint16_t readValue(uint8_t); + void TSISensor_reset(void); private: void sliderRead(void);