Here is some very basic example code of this working without the Arduino library in C++ (although that library was my reference point for this). I am using 2 DACs with different addresses, essentially just sending off and on values to both and testing with an LED. Also worth mentioning that I could only get this working with TransmitDma. There’s probably better ways to do this, but for now this seems to work for me.
To find the DAC addresses I used the example from this post: Porting from Arduino: Wire.h - #8 by Elby
#include "daisy_seed.h"
#include <array>
#include <memory>
#include <string.h>
using namespace daisy;
// uint8_t output_buffer[8];
#define BUFF_SIZE 8
static uint8_t DMA_BUFFER_MEM_SECTION output_buffer[BUFF_SIZE];
int main(void)
{
static DaisySeed seed;
seed.Configure();
seed.Init();
seed.StartLog(true);
System::Delay(1000);
I2CHandle::Config _i2c_config;
_i2c_config.periph = I2CHandle::Config::Peripheral::I2C_1;
_i2c_config.speed = I2CHandle::Config::Speed::I2C_400KHZ;
_i2c_config.mode = I2CHandle::Config::Mode::I2C_MASTER;
_i2c_config.pin_config.scl = {DSY_GPIOB, 8};
_i2c_config.pin_config.sda = {DSY_GPIOB, 9};
// initialise the peripheral
I2CHandle _i2c;
_i2c.Init(_i2c_config);
while(1) {
seed.PrintLine("Running..");
System::Delay(1000);
uint16_t channel_a_value {4000};
uint16_t channel_b_value {2000};
uint16_t channel_c_value {3000};
uint16_t channel_d_value {4095};
output_buffer[0] = static_cast<uint8_t>(channel_a_value >> 8);
output_buffer[1] = static_cast<uint8_t>(channel_a_value & 0xFF);
output_buffer[2] = static_cast<uint8_t>(channel_b_value >> 8);
output_buffer[3] = static_cast<uint8_t>(channel_b_value & 0xFF);
output_buffer[4] = static_cast<uint8_t>(channel_c_value >> 8);
output_buffer[5] = static_cast<uint8_t>(channel_c_value & 0xFF);
output_buffer[6] = static_cast<uint8_t>(channel_d_value >> 8);
output_buffer[7] = static_cast<uint8_t>(channel_d_value & 0xFF);
I2CHandle::Result i2cResult= _i2c.TransmitDma(0x64, &output_buffer[0], 8, NULL, NULL);
if(i2cResult == I2CHandle::Result::OK) {
seed.PrintLine("OK TRANSMISSION 1");
}
I2CHandle::Result i2cResult_2= _i2c.TransmitDma(0x60, &output_buffer[0], 8, NULL, NULL);
if(i2cResult_2 == I2CHandle::Result::OK) {
seed.PrintLine("OK TRANSMISSION 2");
}
System::Delay(1000);
uint16_t channel_a_value_2 {0};
uint16_t channel_b_value_2 {0};
uint16_t channel_c_value_2 {0};
uint16_t channel_d_value_2 {0};
output_buffer[0] = static_cast<uint8_t>(channel_a_value_2 >> 8);
output_buffer[1] = static_cast<uint8_t>(channel_a_value_2 & 0xFF);
output_buffer[2] = static_cast<uint8_t>(channel_b_value_2 >> 8);
output_buffer[3] = static_cast<uint8_t>(channel_b_value_2 & 0xFF);
output_buffer[4] = static_cast<uint8_t>(channel_c_value_2 >> 8);
output_buffer[5] = static_cast<uint8_t>(channel_c_value_2 & 0xFF);
output_buffer[6] = static_cast<uint8_t>(channel_d_value_2 >> 8);
output_buffer[7] = static_cast<uint8_t>(channel_d_value_2 & 0xFF);
I2CHandle::Result i2cResult_3= _i2c.TransmitDma(0x64, &output_buffer[0], 8, NULL, NULL);
if(i2cResult_3 == I2CHandle::Result::OK) {
seed.PrintLine("OK TRANSMISSION 3");
}
I2CHandle::Result i2cResult_4= _i2c.TransmitDma(0x60, &output_buffer[0], 8, NULL, NULL);
if(i2cResult_4 == I2CHandle::Result::OK) {
seed.PrintLine("OK TRANSMISSION 4");
}
}
}