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: MAX31723_Digital_Temperature_Sensor max32630fthr USBDevice
Revision 1:a7990c969d1a, committed 2018-05-12
- Comitter:
- phonemacro
- Date:
- Sat May 12 03:59:43 2018 +0000
- Parent:
- 0:a3f9ce6b99f5
- Child:
- 2:07fde4ba8e91
- Commit message:
- Sample read, writes for the DS4424
Changed in this revision
| DS4424.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/DS4424.lib Thu May 10 22:59:56 2018 +0000 +++ b/DS4424.lib Sat May 12 03:59:43 2018 +0000 @@ -1,1 +1,1 @@ -DS4424#a010119890ed +https://os.mbed.com/teams/MaximIntegrated/code/DS4424_SINK_SOURCE_CURRENT_DAC/#cead66dd3647
--- a/main.cpp Thu May 10 22:59:56 2018 +0000
+++ b/main.cpp Sat May 12 03:59:43 2018 +0000
@@ -41,7 +41,10 @@
DigitalOut rLED(LED1);
DigitalOut gLED(LED2);
DigitalOut bLED(LED3);
-
+
+I2C i2cBus(P3_4, P3_5);
+
+DS4424 ds4424_dac(i2cBus, DS4424::DS4424_I2C_SLAVE_ADRS0, DS4424::DS4424_IC);
// main() runs in its own thread in the OS
// (note the calls to Thread::wait below for delays)
@@ -49,7 +52,7 @@
{
int32_t value[4]={0,0,0,0};
int ret, i;
-
+
DigitalOut rLED(LED1, LED_OFF);
DigitalOut gLED(LED2, LED_OFF);
DigitalOut bLED(LED3, LED_OFF);
@@ -58,18 +61,9 @@
bLED = LED_ON;
gLED = LED_ON;
-// I2C i2cBus(P5_7, P6_0);
- I2C i2cBus(P3_4, P3_5);
- //i2cBus.frequency(400000);
- DS4424 ds4424_dac(i2cBus, DS4424::DS4424_I2C_SLAVE_ADRS0);
+ i2cBus.frequency(400000);
- ret = ds4424_dac.readRaw(value[0], DS4424::REG_OUT0);
- ret = ds4424_dac.readRaw(value[1], DS4424::REG_OUT1);
- ret = ds4424_dac.readRaw(value[2], DS4424::REG_OUT2);
- ret = ds4424_dac.readRaw(value[3], DS4424::REG_OUT3);
- for (i = 0; i < 4; i++) {
- printf("Out%d = %d\r\n", i, value[i]);
- }
+ // read each channel
ret = ds4424_dac.writeRaw(127, DS4424::REG_OUT0);
ret = ds4424_dac.writeRaw(2, DS4424::REG_OUT1);
ret = ds4424_dac.writeRaw(-127, DS4424::REG_OUT2);
@@ -82,11 +76,9 @@
for (i = 0; i < 4; i++) {
printf("Out%d = %d\r\n", i, value[i]);
}
-
- //ret = ds4424_dac.printRawRegs();
- //ret = ds4424_dac.printRegs();
+ printf("\r\n");
- while (true) {
+ while (true) { // Blink the blue-green LED
bLED = !bLED;
gLED = !gLED;
wait(1.0);