Example host software for the Maxim Integrated MAX5715 12-bit 4-channel voltage-output DAC. Hosted on the MAX32625MBED.
Dependencies: MAX5715
Diff: main.cpp
- Revision:
- 6:0bfe0d990850
- Parent:
- 5:e9594321c488
- Child:
- 7:0367e520c682
--- a/main.cpp Thu May 16 19:05:16 2019 +0000 +++ b/main.cpp Thu May 16 19:39:04 2019 +0000 @@ -38,8 +38,18 @@ #include "MAX5715.h" // optional: serial port +// note: some platforms such as Nucleo-F446RE do not support the USBSerial library. +// In those cases, remove the USBDevice lib from the project and rebuild. +#if defined(TARGET_MAX32625MBED) +#include "USBSerial.h" +USBSerial serial; // virtual serial port over USB (DEV connector) +#elif defined(TARGET_MAX32630MBED) +#include "USBSerial.h" +USBSerial serial; // virtual serial port over USB (DEV connector) +#else //#include "USBSerial.h" Serial serial(USBTX, USBRX); // tx, rx +#endif // example code board support //MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3); @@ -96,52 +106,55 @@ // example code main function int main() { - // example code: serial port banner message -#if defined(TARGET_MAX32625MBED) - serial.printf("MAX32625MBED "); -#elif defined(TARGET_MAX32600MBED) - serial.printf("MAX32600MBED "); -#elif defined(TARGET_NUCLEO_F446RE) - serial.printf("NUCLEO_F446RE "); -#endif - serial.printf("MAX5715BOB\r\n"); - - //MAX5715 dac(spi, spi_cs, MAX5715::MAX5715_IC); - //dac.Init(); - - // CODE GENERATOR: example code: member function Init - g_MAX5715_device.Init(); - - // CODE GENERATOR: example code: member function REF - // CODE GENERATOR: example code: device has enumType 'MAX5715_REF_enum_t' - // CODE GENERATOR: TypedefEnum_MAXxxxxx_REF_enum_t_NamesList: REF_EXT, REF_2V500, REF_2V048, REF_4V096, REF_AlwaysOn_EXT, REF_AlwaysOn_2V500, REF_AlwaysOn_2V048, REF_AlwaysOn_4V096 - g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); - - // CODE GENERATOR: example code: has no member function CODE_LOAD - // CODE GENERATOR: example code: member function CODEallLOADall - //uint16_t code = 4095; - //g_MAX5715_device.CODEallLOADall(code); - - // CODE GENERATOR: example code: member function CODEnLOADn - // - uint16_t ch = 0; - uint16_t code = 0xccc; - g_MAX5715_device.CODEnLOADn(ch, code); - // - ch = 1; - code = 0x800; - g_MAX5715_device.CODEnLOADn(ch, code); - // - ch = 2; - code = 0x666; - g_MAX5715_device.CODEnLOADn(ch, code); - // - ch = 3; - code = 0xFFF; - g_MAX5715_device.CODEnLOADn(ch, code); - - // CODE GENERATOR: example code: has no member function ScanManual - // CODE GENERATOR: example code: has no member function ReadAINcode - //wait(1.0); + while (1) + { + // example code: serial port banner message + #if defined(TARGET_MAX32625MBED) + serial.printf("MAX32625MBED "); + #elif defined(TARGET_MAX32600MBED) + serial.printf("MAX32600MBED "); + #elif defined(TARGET_NUCLEO_F446RE) + serial.printf("NUCLEO_F446RE "); + #endif + serial.printf("MAX5715BOB\r\n"); + + //MAX5715 dac(spi, spi_cs, MAX5715::MAX5715_IC); + //dac.Init(); + + // CODE GENERATOR: example code: member function Init + g_MAX5715_device.Init(); + + // CODE GENERATOR: example code: member function REF + // CODE GENERATOR: example code: device has enumType 'MAX5715_REF_enum_t' + // CODE GENERATOR: TypedefEnum_MAXxxxxx_REF_enum_t_NamesList: REF_EXT, REF_2V500, REF_2V048, REF_4V096, REF_AlwaysOn_EXT, REF_AlwaysOn_2V500, REF_AlwaysOn_2V048, REF_AlwaysOn_4V096 + g_MAX5715_device.REF(MAX5715::REF_AlwaysOn_2V500); + + // CODE GENERATOR: example code: has no member function CODE_LOAD + // CODE GENERATOR: example code: member function CODEallLOADall + //uint16_t code = 4095; + //g_MAX5715_device.CODEallLOADall(code); + + // CODE GENERATOR: example code: member function CODEnLOADn + // + uint16_t ch = 0; + uint16_t code = 0xccc; + g_MAX5715_device.CODEnLOADn(ch, code); + // + ch = 1; + code = 0x800; + g_MAX5715_device.CODEnLOADn(ch, code); + // + ch = 2; + code = 0x666; + g_MAX5715_device.CODEnLOADn(ch, code); + // + ch = 3; + code = 0xFFF; + g_MAX5715_device.CODEnLOADn(ch, code); + + // CODE GENERATOR: example code: has no member function ScanManual + // CODE GENERATOR: example code: has no member function ReadAINcode + wait(3.0); + } } //---------- CODE GENERATOR: end testMainCppCodeList