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.
Diff: FastAnalogIn.h
- Revision:
 - 3:c04d8d0493f4
 - Parent:
 - 2:5bcd2f55a294
 
--- a/FastAnalogIn.h	Tue May 14 17:19:45 2013 +0000
+++ b/FastAnalogIn.h	Wed May 15 15:32:34 2013 +0000
@@ -30,13 +30,16 @@
     }
 
     uint16_t read_u16_nowait() {
-        // Return value
         return (uint16_t)ADC0->R[0];
     }
 
-    uint8_t read_u8_nowait() {
-        // Return value
-        return (uint8_t)ADC0->R[0];
+    // 0x0000 => 0x80 (-128)
+    // 0x7fff => 0xFF (-1)
+    // 0x8000 => 0x00 (0)
+    // 0xffff => 0x7f (127)
+    int8_t read_s8_nowait() {
+        int32_t val = read_u16_nowait();
+        return (val + 0x80 - 0x8000) >> 8;
     }
 
     FastAnalogIn(PinName pin)