void HalI2CInit(void) { #ifdef TI_DRIVERS_I2C_INCLUDED Board_initI2C(); // Setup I2C and initialize the driver. I2C_Params_init(&I2CParams); I2CParams.bitRate = I2C_400kHz; I2Chandle = I2C_open(Board_I2C, &I2CParams); if (I2Chandle == NULL) { while(1) { // whait here for ever } } #endif }
/* * ======== main ======== */ int main(void) { /* Call board init functions */ Board_initGeneral(); Board_initGPIO(); Board_initI2C(); /* Turn on user LED */ GPIO_write(Board_LED0, Board_LED_ON); System_printf("Starting the example\nSystem provider is set to SysMin. " "Halt the target to view any SysMin contents in ROV.\n"); /* SysMin will only print to the console when you call flush or exit */ System_flush(); /* Start BIOS */ BIOS_start(); return (0); }
Int main() { Task_Params taskParams; /* Call board init functions */ Board_initGeneral(); Board_initGPIO(); Board_initPWM(); Board_initUART(); Board_initI2C(); GPIO_write(Board_LED0, Board_LED_ON); GPIO_write(Board_LED1, Board_LED_OFF); Task_Params_init(&taskParams); taskParams.priority = 2; objTask[0] = Task_create (Task_IDLE, &taskParams, NULL); Task_Params_init(&taskParams); taskParams.priority = 1; objTask[1] = Task_create (Task_GPIO, &taskParams, NULL); Task_Params_init(&taskParams); taskParams.priority = 1; objTask[2] = Task_create (Task_PWM, &taskParams, NULL); #if 0 //for use Lowlevel SIO API Task_Params_init(&taskParams); taskParams.priority = 1; objTask[3] = Task_create (Task_UART, &taskParams, NULL); #else //for use Highlevel SIO API(printf, scanf) add_device("UART", _MSA, UARTUtils_deviceopen, UARTUtils_deviceclose, UARTUtils_deviceread, UARTUtils_devicewrite, UARTUtils_devicelseek, UARTUtils_deviceunlink, UARTUtils_devicerename); /* Open UART0 for writing to stdout and set buffer */ freopen("UART:0", "w", stdout); setvbuf(stdout, NULL, _IOLBF, 128); /* Open UART0 for reading from stdin and set buffer */ freopen("UART:0", "r", stdin); setvbuf(stdin, NULL, _IOLBF, 128); /* * Initialize UART port 0 used by SysCallback. This and other SysCallback * UART functions are implemented in UARTUtils.c. Calls to System_printf * will go to UART0, the same as printf. */ UARTUtils_systemInit(0); #endif Task_Params_init(&taskParams); taskParams.priority = 1; objTask[4] = Task_create (Task_I2C, &taskParams, NULL); BIOS_start(); /* does not return */ return(0); }