![Infineon MERUS MA2304DNS Скачать руководство пользователя страница 58](http://html1.mh-extra.com/html/infineon/merus-ma2304dns/merus-ma2304dns_user-manual_2055094058.webp)
User Manual
58
V 1.1
2022-09-12
User manual for MERUS™ audio amplifier configurator
MA2304DNS/MA2304PNS
Saving and exporting configurations
6.2.1
Example MCU pseudo-code
To export a header file, select “export configuration” in the configuration drop
-down menu. When prompted,
select a folder to save the files into.
Below is an example MCU code snippet where the device is first muted, DSP data and device registers are
written and then the device is unmuted for playback:
#include “output.h”
#define MA2304_ADDR 0x20
...
int main()
{
amp_mute(true);
amp_write_code(PROGRAM_MEM_ADDR, PROGRAM_CODE, PROGRAM_PACK_SIZE);
amp_write_code(DATA_MEM_ADDR, DATA_CODE, DATA_PACK_SIZE);
amp_write(REG_ADDRESS_1, REG_DATA_1);
amp_write(REG_ADDRESS_2, REG_DATA_2);
amp_mute(false);
return 0;
}
int amp_write_code(uint16_t addr, uint16_t * code, uint16_t size) {
int i = 0;
// Split 16-bit register address into bytes
uint8_t i2c_buffer; // Temporary storage
i2c_buffer = addr >> 8 & 0xff; // Register address MSB
i2c_write (MA2304_ADDR, i2c_buffer); // Send byte through I2C
i2c_buffer = addr & 0xff; // Register address LSB
i2c_write (MA2304_ADDR, i2c_buffer); // Send byte through I2C
// Write data through I2C
for (i = 0; i < size; i++) {
i2c_buffer = code[i] >> 8 & 0xff;
i2c_write (MA2304_ADDR, i2c_buffer);
i2c_buffer = code[i] & 0xff;
i2c_write (MA2304_ADDR, i2c_buffer);
}
}
Figure 76
Example MCU pseudo-code