#include #include #include "test.h" #include "inc/hw_types.h" #include "inc/hw_memmap.h" #include "inc/hw_gpio.h" #include "inc/hw_ints.h" #include "inc/hw_uart.h" #include "inc/hw_sysctl.h" #include "inc/hw_i2c.h" #include "driverlib/fpu.h" #include "driverlib/systick.h" #include "driverlib/sysctl.h" #include "driverlib/pin_map.h" #include "driverlib/rom_map.h" #include "driverlib/debug.h" #include "driverlib/interrupt.h" #include "driverlib/gpio.h" #include "driverlib/uart.h" #include "driverlib/rom.h" #include "driverlib/i2c.h" #define SLAVE 0x3B //***************************************************************************** void PortFunctionInit(void) { // // Enable Peripheral Clocks // MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); /**** * GPIO setting for output */ // // Enable pin PA4 PA5 PA6 PA7 for GPIOOutput // MAP_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); // // Enable pin PC4 PC5 PC6 PC7 for GPIOOutput // MAP_GPIOPinTypeGPIOOutput(GPIO_PORTC_BASE, GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7); // // Enable pin PD3 for GPIOOutput // // MAP_GPIOPinTypeGPIOOutput(GPIO_PORTD_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); // // Enable pin PE0 PE1 PE2 PE3 PE4 for GPIOOutput // MAP_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_4); // // Enable pin PF1 PF2 for GPIOOutput // MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1 | GPIO_PIN_2); // //First open the lock and select the bits we want to modify in the GPIO commit register. // HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x1; // //Now modify the configuration of the pins that we unlocked. //Enable pin PF0 PF3 PF4 for GPIOOutput MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_0 | GPIO_PIN_4 | GPIO_PIN_3); /*** * I2C0 set up */ // Enable pin PB2 for I2C0 I2C0SCL // MAP_GPIOPinConfigure(GPIO_PB2_I2C0SCL); MAP_GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2); // // Enable pin PB3 for I2C0 I2C0SDA // MAP_GPIOPinConfigure(GPIO_PB3_I2C0SDA); MAP_GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3); /* * UART set up */ // Enable pin PA1 for UART0 U0TX // MAP_GPIOPinConfigure(GPIO_PA1_U0TX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_1); // // Enable pin PA0 for UART0 U0RX // MAP_GPIOPinConfigure(GPIO_PA0_U0RX); MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0); /* * USB Set up */ // Enable pin PB0 for USB0 USB0ID // MAP_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_0); // // Enable pin PB1 for USB0 USB0VBUS // MAP_GPIOPinTypeUSBAnalog(GPIO_PORTB_BASE, GPIO_PIN_1); // // Enable pin PD4 for USB0 USB0DM // MAP_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_4); // // Enable pin PD5 for USB0 USB0DP // MAP_GPIOPinTypeUSBAnalog(GPIO_PORTD_BASE, GPIO_PIN_5); } int main(void) { SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_XTAL_16MHZ|SYSCTL_OSC_MAIN); SysCtlDelay(10000); PortFunctionInit(); while(1) { i2c(); } } int i2c(void) { I2CMasterInitExpClk (I2C0_BASE, SysCtlClockGet(), false); SysCtlDelay(10000); I2CMasterSlaveAddrSet (I2C0_BASE, SLAVE, 0); //Software Reset I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x01); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); /* * Clock and Interface Settings * The codec receives: MCLK = 12.288 MHz, * BLCK = 512 kHz, WCLK = 8 kHz */ I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x04); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x03); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x91); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x08); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x0B); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x82); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x88); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x0D); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x03); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x12); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x88); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x8C); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); /* * CONFIGURE PROCESSING BLOCK */ I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3C); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x02); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3D); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x02); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); /* * CONFIGURING POWER SUPPLY */ I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x01); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x02); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x09); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x01); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x08); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x02); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x01); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x0A); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3B); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3D); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x03); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x47); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x32); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x7B); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x01); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); /* * CONFIGURE ADC CHANNEL */ I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x01); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x34); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x80); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x36); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x80); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x37); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x80); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x39); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x80); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3B); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x0C); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3C); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x0C); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x51); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0xC0); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x52); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); /* * CONFIGURE DAC CHANNEL */ I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x01); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x14); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x25); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x0C); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x08); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x08); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x0E); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x08); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x08); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x09); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3C); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x10); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x12); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x41); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x3F); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0xD6); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x30); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x40); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT); while(!I2CMasterBusy(I2C0_BASE)); I2CMasterDataPut(I2C0_BASE, 0x00); I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH); while(!I2CMasterBusy(I2C0_BASE)); return 0; }