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

main.cpp

Committer:
jungkeviny
Date:
2018-07-10
Revision:
0:eb0e7b4d9df3
Child:
1:9f552131dd08

File content as of revision 0:eb0e7b4d9df3:

#include "mbed.h"
#include "max32630fthr.h"
#include "USBSerial.h"

#include "MAX5487.h"

//MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);

// Hardware serial port over DAPLink
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

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;
    
    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;
    while (true) {
//        printf("hi\r\n");
        led1 = !led1;
//        wait(0.5);
        Thread::wait(500);
    }
}