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.
Dependencies: MAX5171
main.cpp@0:5da566e61083, 2019-06-12 (annotated)
- Committer:
- whismanoid
- Date:
- Wed Jun 12 19:26:27 2019 +0000
- Revision:
- 0:5da566e61083
- Child:
- 1:8f712114baf7
initial commit; buildable MAX32625MBED mbed-os-5.11
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: testMainCppCodeList | 
| whismanoid | 0:5da566e61083 | 34 | // CODE GENERATOR: example code includes | 
| whismanoid | 0:5da566e61083 | 35 | // example code includes | 
| whismanoid | 0:5da566e61083 | 36 | #include "mbed.h" | 
| whismanoid | 0:5da566e61083 | 37 | //#include "max32625.h" | 
| whismanoid | 0:5da566e61083 | 38 | #include "MAX5171.h" | 
| whismanoid | 0:5da566e61083 | 39 | |
| whismanoid | 0:5da566e61083 | 40 | // optional: serial port | 
| whismanoid | 0:5da566e61083 | 41 | // note: some platforms such as Nucleo-F446RE do not support the USBSerial library. | 
| whismanoid | 0:5da566e61083 | 42 | // In those cases, remove the USBDevice lib from the project and rebuild. | 
| whismanoid | 0:5da566e61083 | 43 | #if defined(TARGET_MAX32625MBED) | 
| whismanoid | 0:5da566e61083 | 44 | #include "USBSerial.h" | 
| whismanoid | 0:5da566e61083 | 45 | USBSerial serial; // virtual serial port over USB (DEV connector) | 
| whismanoid | 0:5da566e61083 | 46 | #elif defined(TARGET_MAX32630MBED) | 
| whismanoid | 0:5da566e61083 | 47 | #include "USBSerial.h" | 
| whismanoid | 0:5da566e61083 | 48 | USBSerial serial; // virtual serial port over USB (DEV connector) | 
| whismanoid | 0:5da566e61083 | 49 | #else | 
| whismanoid | 0:5da566e61083 | 50 | //#include "USBSerial.h" | 
| whismanoid | 0:5da566e61083 | 51 | Serial serial(USBTX, USBRX); // tx, rx | 
| whismanoid | 0:5da566e61083 | 52 | #endif | 
| whismanoid | 0:5da566e61083 | 53 | |
| whismanoid | 0:5da566e61083 | 54 | // example code board support | 
| whismanoid | 0:5da566e61083 | 55 | //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); | 
| whismanoid | 0:5da566e61083 | 56 | //DigitalOut rLED(LED1); | 
| whismanoid | 0:5da566e61083 | 57 | //DigitalOut gLED(LED2); | 
| whismanoid | 0:5da566e61083 | 58 | //DigitalOut bLED(LED3); | 
| whismanoid | 0:5da566e61083 | 59 | // | 
| whismanoid | 0:5da566e61083 | 60 | // Arduino "shield" connector port definitions (MAX32625MBED shown) | 
| whismanoid | 0:5da566e61083 | 61 | #if defined(TARGET_MAX32625MBED) | 
| whismanoid | 0:5da566e61083 | 62 | #define A0 AIN_0 | 
| whismanoid | 0:5da566e61083 | 63 | #define A1 AIN_1 | 
| whismanoid | 0:5da566e61083 | 64 | #define A2 AIN_2 | 
| whismanoid | 0:5da566e61083 | 65 | #define A3 AIN_3 | 
| whismanoid | 0:5da566e61083 | 66 | #define D0 P0_0 | 
| whismanoid | 0:5da566e61083 | 67 | #define D1 P0_1 | 
| whismanoid | 0:5da566e61083 | 68 | #define D2 P0_2 | 
| whismanoid | 0:5da566e61083 | 69 | #define D3 P0_3 | 
| whismanoid | 0:5da566e61083 | 70 | #define D4 P0_4 | 
| whismanoid | 0:5da566e61083 | 71 | #define D5 P0_5 | 
| whismanoid | 0:5da566e61083 | 72 | #define D6 P0_6 | 
| whismanoid | 0:5da566e61083 | 73 | #define D7 P0_7 | 
| whismanoid | 0:5da566e61083 | 74 | #define D8 P1_4 | 
| whismanoid | 0:5da566e61083 | 75 | #define D9 P1_5 | 
| whismanoid | 0:5da566e61083 | 76 | #define D10 P1_3 | 
| whismanoid | 0:5da566e61083 | 77 | #define D11 P1_1 | 
| whismanoid | 0:5da566e61083 | 78 | #define D12 P1_2 | 
| whismanoid | 0:5da566e61083 | 79 | #define D13 P1_0 | 
| whismanoid | 0:5da566e61083 | 80 | #endif | 
| whismanoid | 0:5da566e61083 | 81 | |
| whismanoid | 0:5da566e61083 | 82 | // example code declare SPI interface | 
| whismanoid | 0:5da566e61083 | 83 | #if defined(TARGET_MAX32625MBED) | 
| whismanoid | 0:5da566e61083 | 84 | 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 | 85 | DigitalOut spi_cs(SPI1_SS); // TARGET_MAX32625MBED: P1_3 Arduino 10-pin header D10 | 
| whismanoid | 0:5da566e61083 | 86 | #elif defined(TARGET_MAX32600MBED) | 
| whismanoid | 0:5da566e61083 | 87 | SPI spi(SPI2_MOSI, SPI2_MISO, SPI2_SCK); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 | 
| whismanoid | 0:5da566e61083 | 88 | DigitalOut spi_cs(SPI2_SS); // Generic: Arduino 10-pin header D10 | 
| whismanoid | 0:5da566e61083 | 89 | #else | 
| whismanoid | 0:5da566e61083 | 90 | SPI spi(D11, D12, D13); // mosi, miso, sclk spi1 TARGET_MAX32600MBED: Arduino 10-pin header D11 D12 D13 | 
| whismanoid | 0:5da566e61083 | 91 | DigitalOut spi_cs(D10); // Generic: Arduino 10-pin header D10 | 
| whismanoid | 0:5da566e61083 | 92 | #endif | 
| whismanoid | 0:5da566e61083 | 93 | |
| whismanoid | 0:5da566e61083 | 94 | // example code declare GPIO interface pins | 
| whismanoid | 0:5da566e61083 | 95 | // AnalogOut FB_pin(Px_x_PortName_To_Be_Determined); // Analog Input to MAX5171 device | 
| whismanoid | 0:5da566e61083 | 96 | DigitalOut RS_pin(D9); // Digital Configuration Input to MAX5171 device | 
| whismanoid | 0:5da566e61083 | 97 | DigitalOut PDLb_pin(D8); // Digital Configuration Input to MAX5171 device | 
| whismanoid | 0:5da566e61083 | 98 | DigitalOut CLRb_pin(D7); // Digital Configuration Input to MAX5171 device | 
| whismanoid | 0:5da566e61083 | 99 | DigitalOut SHDN_pin(D6); // Digital Configuration Input to MAX5171 device | 
| whismanoid | 0:5da566e61083 | 100 | // AnalogIn OUT_pin(A0); // Analog Output from MAX5171 device | 
| whismanoid | 0:5da566e61083 | 101 | DigitalIn UPO_pin(D5); // Digital General-Purpose Output from MAX5171 device | 
| whismanoid | 0:5da566e61083 | 102 | // example code declare device instance | 
| whismanoid | 0:5da566e61083 | 103 | MAX5171 g_MAX5171_device(spi, spi_cs, RS_pin, PDLb_pin, CLRb_pin, SHDN_pin, UPO_pin, MAX5171::MAX5171_IC); | 
| whismanoid | 0:5da566e61083 | 104 | |
| whismanoid | 0:5da566e61083 | 105 | // example code main function | 
| whismanoid | 0:5da566e61083 | 106 | int main() | 
| whismanoid | 0:5da566e61083 | 107 | { | 
| whismanoid | 0:5da566e61083 | 108 | while (1) | 
| whismanoid | 0:5da566e61083 | 109 | { | 
| whismanoid | 0:5da566e61083 | 110 | // example code: serial port banner message | 
| whismanoid | 0:5da566e61083 | 111 | #if defined(TARGET_MAX32625MBED) | 
| whismanoid | 0:5da566e61083 | 112 | serial.printf("MAX32625MBED "); | 
| whismanoid | 0:5da566e61083 | 113 | #elif defined(TARGET_MAX32600MBED) | 
| whismanoid | 0:5da566e61083 | 114 | serial.printf("MAX32600MBED "); | 
| whismanoid | 0:5da566e61083 | 115 | #elif defined(TARGET_NUCLEO_F446RE) | 
| whismanoid | 0:5da566e61083 | 116 | serial.printf("NUCLEO_F446RE "); | 
| whismanoid | 0:5da566e61083 | 117 | #endif | 
| whismanoid | 0:5da566e61083 | 118 | serial.printf("MAX5715BOB\r\n"); | 
| whismanoid | 0:5da566e61083 | 119 | |
| whismanoid | 0:5da566e61083 | 120 | //MAX5171 dac(spi, spi_cs, MAX5171::MAX5171_IC); | 
| whismanoid | 0:5da566e61083 | 121 | //dac.Init(); | 
| whismanoid | 0:5da566e61083 | 122 | |
| whismanoid | 0:5da566e61083 | 123 | // CODE GENERATOR: example code: member function Init | 
| whismanoid | 0:5da566e61083 | 124 | g_MAX5171_device.Init(); | 
| whismanoid | 0:5da566e61083 | 125 | |
| whismanoid | 0:5da566e61083 | 126 | // CODE GENERATOR: example code: has no member function REF | 
| whismanoid | 0:5da566e61083 | 127 | // CODE GENERATOR: example code: member function CODE_LOAD | 
| whismanoid | 0:5da566e61083 | 128 | // | 
| whismanoid | 0:5da566e61083 | 129 | uint16_t code = 0xccc; | 
| whismanoid | 0:5da566e61083 | 130 | g_MAX5171_device.CODE_LOAD(code); | 
| whismanoid | 0:5da566e61083 | 131 | // | 
| whismanoid | 0:5da566e61083 | 132 | code = 0x800; | 
| whismanoid | 0:5da566e61083 | 133 | g_MAX5171_device.CODE_LOAD(code); | 
| whismanoid | 0:5da566e61083 | 134 | // | 
| whismanoid | 0:5da566e61083 | 135 | code = 0x666; | 
| whismanoid | 0:5da566e61083 | 136 | g_MAX5171_device.CODE_LOAD(code); | 
| whismanoid | 0:5da566e61083 | 137 | // | 
| whismanoid | 0:5da566e61083 | 138 | code = 0xFFF; | 
| whismanoid | 0:5da566e61083 | 139 | g_MAX5171_device.CODE_LOAD(code); | 
| whismanoid | 0:5da566e61083 | 140 | |
| whismanoid | 0:5da566e61083 | 141 | // CODE GENERATOR: example code: has no member function CODEallLOADall | 
| whismanoid | 0:5da566e61083 | 142 | // CODE GENERATOR: example code: has no member function CODEnLOADn | 
| whismanoid | 0:5da566e61083 | 143 | // CODE GENERATOR: example code: has no member function ScanManual | 
| whismanoid | 0:5da566e61083 | 144 | // CODE GENERATOR: example code: has no member function ReadAINcode | 
| whismanoid | 0:5da566e61083 | 145 | wait(3.0); | 
| whismanoid | 0:5da566e61083 | 146 | } | 
| whismanoid | 0:5da566e61083 | 147 | } | 
| whismanoid | 0:5da566e61083 | 148 | //---------- CODE GENERATOR: end testMainCppCodeList | 
 MAX5171BOB
            MAX5171BOB