Example host software for the Maxim Integrated MAX5487, MAX5488, MAX5489 Digital Pot/Digital Potentiometer/Rheostat/Variable Resistor. Hosted on the MAX32630FTHR FeatherWing micro-controller board.

Dependencies:   MAX5487_Digital_Pot_Potentiometer_Rheostat_Resistor_Wiper USBDevice max32630fthr

Revision:
1:9f552131dd08
Parent:
0:eb0e7b4d9df3
--- a/main.cpp	Tue Jul 10 05:28:26 2018 +0000
+++ b/main.cpp	Sat Jul 14 04:25:58 2018 +0000
@@ -1,45 +1,28 @@
 #include "mbed.h"
 #include "max32630fthr.h"
 #include "USBSerial.h"
-
 #include "MAX5487.h"
 
-//MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
-
-// Hardware serial port over DAPLink
+MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
 Serial daplink(P2_1, P2_0);
-
-// Virtual serial port over USB
 USBSerial microUSB; 
-
-
 DigitalOut led1(LED1); // led to blink
-DigitalOut selectPin(P3_0); // Pin 6_0 is used to drive chip enable low
-
+DigitalOut selectPin(P3_0); // Pin 3_0 is used to drive chip enable low
 SPI spi(P5_1, P5_2, P5_0); // mosi, miso, sclk
 
-MAX32630FTHR pegasus;
-
-// main() runs in its own thread in the OS
 int main() {
-    pegasus.init(MAX32630FTHR::VIO_3V3);
-    
-    selectPin=1;
+    MAX5487 test(spi, selectPin);
     
     spi.format(8,0);
-    
     spi.frequency(1000000);
     
-    selectPin=0;
-    int test1 = spi.write(0x01);
-    printf("returned value 1: %d\r\n", test1);
-    int test2 = spi.write(0xFF);
-    printf("returned value 2: %d\r\n", test2);
-    selectPin=1;
+    // Write a command
+    test.writeCommand(MAX5487::Wiper_RegA, 0x55);
+    test.writeCommand(MAX5487::Copy_Wiper_RegA_to_NV_RegA);
+    
+    // Blink LED
     while (true) {
-//        printf("hi\r\n");
         led1 = !led1;
-//        wait(0.5);
         Thread::wait(500);
     }
 }