Example host software for the Maxim Integrated MAX5171 14-bit Force/Sense DAC. Hosted on the MAX32625MBED.
Dependencies: MAX5171
main.cpp@2:74267105d67b, 2019-06-21 (annotated)
- Committer:
- whismanoid
- Date:
- Fri Jun 21 08:18:14 2019 +0000
- Revision:
- 2:74267105d67b
- Parent:
- 1:8f712114baf7
- Child:
- 3:80bae2311ddb
VRef initialization in MAX5171 class
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
whismanoid | 0:5da566e61083 | 1 | // /******************************************************************************* |
whismanoid | 0:5da566e61083 | 2 | // * Copyright (C) 2019 Maxim Integrated Products, Inc., All Rights Reserved. |
whismanoid | 0:5da566e61083 | 3 | // * |
whismanoid | 0:5da566e61083 | 4 | // * Permission is hereby granted, free of charge, to any person obtaining a |
whismanoid | 0:5da566e61083 | 5 | // * copy of this software and associated documentation files (the "Software"), |
whismanoid | 0:5da566e61083 | 6 | // * to deal in the Software without restriction, including without limitation |
whismanoid | 0:5da566e61083 | 7 | // * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
whismanoid | 0:5da566e61083 | 8 | // * and/or sell copies of the Software, and to permit persons to whom the |
whismanoid | 0:5da566e61083 | 9 | // * Software is furnished to do so, subject to the following conditions: |
whismanoid | 0:5da566e61083 | 10 | // * |
whismanoid | 0:5da566e61083 | 11 | // * The above copyright notice and this permission notice shall be included |
whismanoid | 0:5da566e61083 | 12 | // * in all copies or substantial portions of the Software. |
whismanoid | 0:5da566e61083 | 13 | // * |
whismanoid | 0:5da566e61083 | 14 | // * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
whismanoid | 0:5da566e61083 | 15 | // * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
whismanoid | 0:5da566e61083 | 16 | // * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
whismanoid | 0:5da566e61083 | 17 | // * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES |
whismanoid | 0:5da566e61083 | 18 | // * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
whismanoid | 0:5da566e61083 | 19 | // * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
whismanoid | 0:5da566e61083 | 20 | // * OTHER DEALINGS IN THE SOFTWARE. |
whismanoid | 0:5da566e61083 | 21 | // * |
whismanoid | 0:5da566e61083 | 22 | // * Except as contained in this notice, the name of Maxim Integrated |
whismanoid | 0:5da566e61083 | 23 | // * Products, Inc. shall not be used except as stated in the Maxim Integrated |
whismanoid | 0:5da566e61083 | 24 | // * Products, Inc. Branding Policy. |
whismanoid | 0:5da566e61083 | 25 | // * |
whismanoid | 0:5da566e61083 | 26 | // * The mere transfer of this software does not imply any licenses |
whismanoid | 0:5da566e61083 | 27 | // * of trade secrets, proprietary technology, copyrights, patents, |
whismanoid | 0:5da566e61083 | 28 | // * trademarks, maskwork rights, or any other form of intellectual |
whismanoid | 0:5da566e61083 | 29 | // * property whatsoever. Maxim Integrated Products, Inc. retains all |
whismanoid | 0:5da566e61083 | 30 | // * ownership rights. |
whismanoid | 0:5da566e61083 | 31 | // ******************************************************************************* |
whismanoid | 0:5da566e61083 | 32 | // */ |
whismanoid | 0:5da566e61083 | 33 | // CODE GENERATOR: example code includes |
whismanoid | 0:5da566e61083 | 34 | // example code includes |
whismanoid | 0:5da566e61083 | 35 | #include "mbed.h" |
whismanoid | 0:5da566e61083 | 36 | //#include "max32625.h" |
whismanoid | 0:5da566e61083 | 37 | #include "MAX5171.h" |
whismanoid | 0:5da566e61083 | 38 | |
whismanoid | 0:5da566e61083 | 39 | // example code board support |
whismanoid | 0:5da566e61083 | 40 | //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); |
whismanoid | 0:5da566e61083 | 41 | //DigitalOut rLED(LED1); |
whismanoid | 0:5da566e61083 | 42 | //DigitalOut gLED(LED2); |
whismanoid | 0:5da566e61083 | 43 | //DigitalOut bLED(LED3); |
whismanoid | 0:5da566e61083 | 44 | // |
whismanoid | 0:5da566e61083 | 45 | // Arduino "shield" connector port definitions (MAX32625MBED shown) |
whismanoid | 0:5da566e61083 | 46 | #if defined(TARGET_MAX32625MBED) |
whismanoid | 0:5da566e61083 | 47 | #define A0 AIN_0 |
whismanoid | 0:5da566e61083 | 48 | #define A1 AIN_1 |
whismanoid | 0:5da566e61083 | 49 | #define A2 AIN_2 |
whismanoid | 0:5da566e61083 | 50 | #define A3 AIN_3 |
whismanoid | 0:5da566e61083 | 51 | #define D0 P0_0 |
whismanoid | 0:5da566e61083 | 52 | #define D1 P0_1 |
whismanoid | 0:5da566e61083 | 53 | #define D2 P0_2 |
whismanoid | 0:5da566e61083 | 54 | #define D3 P0_3 |
whismanoid | 0:5da566e61083 | 55 | #define D4 P0_4 |
whismanoid | 0:5da566e61083 | 56 | #define D5 P0_5 |
whismanoid | 0:5da566e61083 | 57 | #define D6 P0_6 |
whismanoid | 0:5da566e61083 | 58 | #define D7 P0_7 |
whismanoid | 0:5da566e61083 | 59 | #define D8 P1_4 |
whismanoid | 0:5da566e61083 | 60 | #define D9 P1_5 |
whismanoid | 0:5da566e61083 | 61 | #define D10 P1_3 |
whismanoid | 0:5da566e61083 | 62 | #define D11 P1_1 |
whismanoid | 0:5da566e61083 | 63 | #define D12 P1_2 |
whismanoid | 0:5da566e61083 | 64 | #define D13 P1_0 |
whismanoid | 0:5da566e61083 | 65 | #endif |
whismanoid | 0:5da566e61083 | 66 | |
whismanoid | 0:5da566e61083 | 67 | // example code declare SPI interface |
whismanoid | 0:5da566e61083 | 68 | #if defined(TARGET_MAX32625MBED) |
whismanoid | 0:5da566e61083 | 69 | SPI spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); // mosi, miso, sclk spi1 TARGET_MAX32625MBED: P1_1 P1_2 P1_0 Arduino 10-pin header D11 D12 D13 |
whismanoid | 0:5da566e61083 | 70 | DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10 |
whismanoid | 0:5da566e61083 | 71 | #elif defined(TARGET_MAX32600MBED) |
whismanoid | 0:5da566e61083 | 72 | SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 |
whismanoid | 0:5da566e61083 | 73 | DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10 |
whismanoid | 0:5da566e61083 | 74 | #else |
whismanoid | 0:5da566e61083 | 75 | SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 |
whismanoid | 0:5da566e61083 | 76 | DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10 |
whismanoid | 0:5da566e61083 | 77 | #endif |
whismanoid | 0:5da566e61083 | 78 | |
whismanoid | 0:5da566e61083 | 79 | // example code declare GPIO interface pins |
whismanoid | 0:5da566e61083 | 80 | // AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device |
whismanoid | 0:5da566e61083 | 81 | DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:5da566e61083 | 82 | DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:5da566e61083 | 83 | DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:5da566e61083 | 84 | DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device |
whismanoid | 0:5da566e61083 | 85 | // AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device |
whismanoid | 0:5da566e61083 | 86 | DigitalIn UPO_pin(D5); // Digital General-Purpose Output from MAX5171 device |
whismanoid | 0:5da566e61083 | 87 | // example code declare device instance |
whismanoid | 0:5da566e61083 | 88 | MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC); |
whismanoid | 0:5da566e61083 | 89 | |
whismanoid | 0:5da566e61083 | 90 | // example code main function |
whismanoid | 0:5da566e61083 | 91 | int main() |
whismanoid | 0:5da566e61083 | 92 | { |
whismanoid | 0:5da566e61083 | 93 | while (1) |
whismanoid | 0:5da566e61083 | 94 | { |
whismanoid | 0:5da566e61083 | 95 | // CODE GENERATOR: example code: member function Init |
whismanoid | 0:5da566e61083 | 96 | g_MAX5171_device.Init(); |
whismanoid | 0:5da566e61083 | 97 | |
whismanoid | 0:5da566e61083 | 98 | // CODE GENERATOR: example code: has no member function REF |
whismanoid | 0:5da566e61083 | 99 | // CODE GENERATOR: example code: member function CODE_LOAD |
whismanoid | 0:5da566e61083 | 100 | // |
whismanoid | 0:5da566e61083 | 101 | uint16_t code = 0xccc; |
whismanoid | 0:5da566e61083 | 102 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:5da566e61083 | 103 | // |
whismanoid | 0:5da566e61083 | 104 | code = 0x800; |
whismanoid | 0:5da566e61083 | 105 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:5da566e61083 | 106 | // |
whismanoid | 0:5da566e61083 | 107 | code = 0x666; |
whismanoid | 0:5da566e61083 | 108 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:5da566e61083 | 109 | // |
whismanoid | 0:5da566e61083 | 110 | code = 0xFFF; |
whismanoid | 0:5da566e61083 | 111 | g_MAX5171_device.CODE_LOAD(code); |
whismanoid | 0:5da566e61083 | 112 | |
whismanoid | 0:5da566e61083 | 113 | // CODE GENERATOR: example code: has no member function CODEallLOADall |
whismanoid | 0:5da566e61083 | 114 | // CODE GENERATOR: example code: has no member function CODEnLOADn |
whismanoid | 0:5da566e61083 | 115 | // CODE GENERATOR: example code: has no member function ScanManual |
whismanoid | 0:5da566e61083 | 116 | // CODE GENERATOR: example code: has no member function ReadAINcode |
whismanoid | 0:5da566e61083 | 117 | wait(3.0); |
whismanoid | 0:5da566e61083 | 118 | } |
whismanoid | 0:5da566e61083 | 119 | } |