void I2C_Init(unsigned long ulBase)
{
	I2CBase = ulBase;

	MAP_I2CMasterInitExpClk(I2CBase, SYSTEM_CLOCK, false);
	MAP_I2CMasterEnable(I2CBase);
}
Beispiel #2
0
int main(void) {
	
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
	sysClock = SysCtlClockGet();

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

	MAP_GPIOPinConfigure(GPIO_PD1_I2C3SDA);
	MAP_GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
	MAP_GPIOPinConfigure(GPIO_PD0_I2C3SCL);
	MAP_GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);

	MAP_I2CMasterInitExpClk(I2C3_BASE, sysClock, 0);

	pRTC->address = RTC_addr;
	SysCtlDelay(20000);
	setupRTC(pRTC);
	SysCtlDelay(20000);
	setTime(pRTC);
	SysCtlDelay(20000);
	getTime(pRTC);

	return 0;
}
Beispiel #3
0
void TwoWire::begin(void)
{
	MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
	MAP_PinTypeI2C(PIN_01, PIN_MODE_1);
	MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
	MAP_PRCMPeripheralReset(PRCM_I2CA0);
	MAP_I2CMasterInitExpClk(I2C_BASE, F_CPU, true);
}
Beispiel #4
0
int ti_arm_mcu_i2c_init(int port)
{
    const ti_arm_mcu_i2c_t *i2c = &ti_arm_mcu_i2cs[port];

    ti_arm_mcu_periph_enable(i2c->periph);
    MAP_I2CMasterInitExpClk(i2c->base, platform.get_system_clock(), 0);
    ti_arm_mcu_pin_mode_i2c(i2c->scl, 1, i2c->scl_af);
    ti_arm_mcu_pin_mode_i2c(i2c->sda, 0, i2c->sda_af);
    return 0;
}
Beispiel #5
0
//*****************************************************************************
//
//!     I2CInit
//!    
//!	\param                      Delay  
//!     \return                     None                            
//
//*****************************************************************************
unsigned long I2CInit() {
	// Enable I2C Peripheral
	MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralReset(PRCM_I2CA0);

	// Configure I2C module, 400 Kbps fast mode
	MAP_I2CMasterInitExpClk(I2CA0_BASE, 80000000, false);
	//  MAP_I2CMasterDisable(I2CA0_BASE);

	return 0;
}
Beispiel #6
0
//*****************************************************************************
//
//!     I2CInit
//!    
//!	\param                      Delay  
//!     \return                     None                            
//
//*****************************************************************************
unsigned long I2CInit()
{
    // Enable I2C Peripheral 
    MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralReset(PRCM_I2CA0);

    // Configure I2C module, 400 Kbps slow mode
    MAP_I2CMasterInitExpClk(I2CA0_BASE,80000000,false);
    //  MAP_I2CMasterDisable(I2CA0_BASE);
    I2CMasterGlitchFilterConfigSet(I2CA0_BASE , I2C_MASTER_GLITCH_FILTER_8);

    return 0;
}
Beispiel #7
0
int i2c_init(i2c_connection conn) {
  struct i2c_state *c = (struct i2c_state *) conn;
  c->base = I2CA0_BASE;
  c->sda_pin_mode = MAP_PinModeGet(c->scl_pin);
  MAP_PinConfigGet(c->sda_pin, &c->sda_pin_strength, &c->sda_pin_type);
  MAP_PinTypeI2C(c->sda_pin, PIN_MODE_1); /* SDA */
  c->scl_pin_mode = MAP_PinModeGet(c->scl_pin);
  MAP_PinConfigGet(c->scl_pin, &c->scl_pin_strength, &c->scl_pin_type);
  MAP_PinTypeI2C(c->scl_pin, PIN_MODE_1); /* SCL */
  MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
  MAP_PRCMPeripheralReset(PRCM_I2CA0);
  MAP_I2CMasterInitExpClk(c->base, SYS_CLK, 0 /* 100 KHz */);
  return 0;
}
int main(void)
{
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |SYSCTL_XTAL_12MHZ); //50MHZ

	//
	// Enable peripherals to operate when CPU is in sleep.
	//
	MAP_SysCtlPeripheralClockGating(true);

	//
	// Configure SysTick to occur 1000 times per second, to use as a time
	// reference.  Enable SysTick to generate interrupts.
	//
	MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKS_PER_SECOND);
	MAP_SysTickIntEnable();
	MAP_SysTickEnable();

	//
	// Get the current processor clock frequency.
	//
	ulClockMS = MAP_SysCtlClockGet() / (3 * 1000);

	// init Serial Comm
	initSerialComm(230400);

	// init SSI0 in slave mode
	initSPIComm();

#ifdef DEBUG
	UARTprintf("Setting up PID\n");
#endif
	initCarPID();
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef DEBUG
	UARTprintf("Setting up PWM ... \n");
#endif
	configurePWM();
	configureGPIO();
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef DEBUG
	UARTprintf("Setting up Servo ... \n");
#endif
	servo_init();
	servo_setPosition(90);
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef DEBUG
	UARTprintf("Starting QEI...");
#endif
	encoder_init();
#ifdef DEBUG
	UARTprintf("done\n");
#endif

#ifdef USE_I2C
#ifdef DEBUG
	UARTprintf("Setting up I2C\n");
#endif
	//I2C
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	MAP_GPIOPinTypeI2C(GPIO_PORTB_AHB_BASE,GPIO_PIN_2 | GPIO_PIN_3);
	MAP_I2CMasterInitExpClk(I2C0_MASTER_BASE,SysCtlClockGet(),true);  //false = 100khz , true = 400khz
	I2CMasterTimeoutSet(I2C0_MASTER_BASE, 1000);
#ifdef DEBUG
	UARTprintf("done\n");
#endif
#endif

#ifdef USE_I2C
#ifdef USE_INA226
#ifdef DEBUG
	UARTprintf("Setting up INA226\n");
#endif
	initINA226();
#ifdef DEBUG
	UARTprintf("done\n");
#endif
#endif
#endif


	while (1)
	{

	}
}