Beispiel #1
0
/*
 *  ======== Board_openI2C ========
 *  Initialize the I2C driver.
 *  Initialize the I2C port's pins.
 *  Open the I2C port.
 */
I2C_Handle Board_openI2C(UInt i2cPortIndex, I2C_Params *i2cParams)
{
    
    /* Initialize the I2C driver */
    /* By design, I2C_init() is idempotent */
    I2C_init();
    
    /* initialize the pins associated with the respective I2C */
    switch (i2cPortIndex) {
        case 0:
            /*
             * Configure LaunchPad P1.9 as a I2C pin: LaunchPad Sensor Data (via I2C)
             *     device pin: 1 (I2C_SCL)
             *     Wiring id : 9
             */
            MAP_PinTypeI2C(PIN_01, PIN_MODE_1);

            /*
             * Configure LaunchPad P1.10 as a I2C pin: LaunchPad Sensor Data (via I2C)
             *     device pin: 2 (I2C_SDA)
             *     Wiring id : 10
             */
            MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
            break;

        default:
            return (NULL);
    }

    /* open the I2C */
    return (I2C_open(i2cPortIndex, i2cParams));
}
Beispiel #2
0
//*****************************************************************************
void
PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_55 for UART0 UART0_TX
    //
    MAP_PinTypeUART(PIN_55, PIN_MODE_3);

    //
    // Configure PIN_57 for UART0 UART0_RX
    //
    MAP_PinTypeUART(PIN_57, PIN_MODE_3);

    //
    // Configure PIN_01 for I2C0 I2C_SCL
    //
    MAP_PinTypeI2C(PIN_01, PIN_MODE_1);

    //
    // Configure PIN_02 for I2C0 I2C_SDA
    //
    MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
}
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
void InitGPIO(void)
{
	/* Activate GPIO clock per port. Not sure of which ports we use, so enable everything */
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA3, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA4, PRCM_RUN_MODE_CLK);

    /* Configure UART pins */
    MAP_PinTypeUART(PIN_55, PIN_MODE_3);
    MAP_PinTypeUART(PIN_57, PIN_MODE_3);

    /* Configure I2C pins */
    MAP_PinTypeI2C(PIN_01, PIN_MODE_1);
    MAP_PinTypeI2C(PIN_02, PIN_MODE_1);

    /* COngifure current sense ADC inputs */
    MAP_PinTypeADC(AISEN,PIN_MODE_255);
    MAP_PinTypeADC(BISEN,PIN_MODE_255);
    MAP_ADCChannelEnable(ADC_BASE, AISENx);
    MAP_ADCChannelEnable(ADC_BASE, BISENx);
    MAP_ADCEnable(ADC_BASE);

	/* Set pin mode for DIP and LED pins */
	MAP_PinTypeGPIO(RLED, PIN_MODE_0, false);
	MAP_PinTypeGPIO(BLED, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP1, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP2, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP3, PIN_MODE_0, false);
	MAP_PinTypeGPIO(DIP4, PIN_MODE_0, false);
	MAP_PinTypeGPIO(ODO1, PIN_MODE_0, false);
	MAP_PinTypeGPIO(ODO2, PIN_MODE_0, false);

	/* Get port name and bin number from GPIO number (TI lookup table) LED, DIP, ODO */
	GPIO_IF_GetPortNPin(RLEDx, &port_rled, &pin_rled);
	GPIO_IF_GetPortNPin(BLEDx, &port_bled, &pin_bled);
	GPIO_IF_GetPortNPin(DIP1x, &port_dip1, &pin_dip1);
	GPIO_IF_GetPortNPin(DIP2x, &port_dip2, &pin_dip2);
	GPIO_IF_GetPortNPin(DIP3x, &port_dip3, &pin_dip3);
	GPIO_IF_GetPortNPin(DIP4x, &port_dip4, &pin_dip4);
	GPIO_IF_GetPortNPin(ODO1x, &port_odo1, &pin_odo1);
	GPIO_IF_GetPortNPin(ODO2x, &port_odo2, &pin_odo2);

	/* Set pin direction LED, DIP, ODO */
	GPIODirModeSet(port_rled, pin_rled, 1);
	GPIODirModeSet(port_bled, pin_bled, 1);
	GPIODirModeSet(port_dip1, pin_dip1, 0);
	GPIODirModeSet(port_dip2, pin_dip2, 0);
	GPIODirModeSet(port_dip3, pin_dip3, 0);
	GPIODirModeSet(port_dip4, pin_dip4, 0);
	GPIODirModeSet(port_odo1, pin_odo1, 0);
	GPIODirModeSet(port_odo2, pin_odo2, 0);
}
Beispiel #5
0
int main() {
#ifndef USE_TIRTOS
  MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]);
#endif
  MAP_IntEnable(FAULT_SYSTICK);
  MAP_IntMasterEnable();
  PRCMCC3200MCUInit();

  /* Console UART init. */
  MAP_PRCMPeripheralClkEnable(CONSOLE_UART_PERIPH, PRCM_RUN_MODE_CLK);
  MAP_PinTypeUART(PIN_55, PIN_MODE_3); /* PIN_55 -> UART0_TX */
  MAP_PinTypeUART(PIN_57, PIN_MODE_3); /* PIN_57 -> UART0_RX */
  MAP_UARTConfigSetExpClk(
      CONSOLE_UART, MAP_PRCMPeripheralClockGet(CONSOLE_UART_PERIPH),
      CONSOLE_BAUD_RATE,
      (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
  MAP_UARTFIFOLevelSet(CONSOLE_UART, UART_FIFO_TX1_8, UART_FIFO_RX4_8);
  MAP_UARTFIFOEnable(CONSOLE_UART);

  setvbuf(stdout, NULL, _IOLBF, 0);
  setvbuf(stderr, NULL, _IOLBF, 0);
  cs_log_set_level(LL_INFO);
  cs_log_set_file(stdout);

  LOG(LL_INFO, ("Hello, world!"));

  MAP_PinTypeI2C(PIN_01, PIN_MODE_1); /* SDA */
  MAP_PinTypeI2C(PIN_02, PIN_MODE_1); /* SCL */
  I2C_IF_Open(I2C_MASTER_MODE_FST);

  /* Set up the red LED. Note that amber and green cannot be used as they share
   * pins with I2C. */
  MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
  MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
  MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);
  GPIO_IF_LedConfigure(LED1);
  GPIO_IF_LedOn(MCU_RED_LED_GPIO);

  if (VStartSimpleLinkSpawnTask(8) != 0) {
    LOG(LL_ERROR, ("Failed to create SL task"));
  }

  if (!mg_start_task(MG_TASK_PRIORITY, MG_TASK_STACK_SIZE, mg_init)) {
    LOG(LL_ERROR, ("Failed to create MG task"));
  }

  osi_start();

  return 0;
}
Beispiel #6
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;
}
Beispiel #7
0
//*****************************************************************************
void
PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_55 for UART0 UART0_TX
    //
    MAP_PinTypeUART(PIN_55, PIN_MODE_3);

    //
    // Configure PIN_57 for UART0 UART0_RX
    //
    MAP_PinTypeUART(PIN_57, PIN_MODE_3);

    //
    // Configure PIN_58 for GPIOInput
    //
    MAP_PinTypeGPIO(PIN_58, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA0_BASE, 0x8, GPIO_DIR_MODE_IN);

    //
    // Configure PIN_64 for GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_01 for I2C0 I2C_SCL
    //
    MAP_PinTypeI2C(PIN_01, PIN_MODE_1);

    //
    // Configure PIN_02 for I2C0 I2C_SDA
    //
    MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
}
Beispiel #8
0
/*
 *  ======== Board_initGeneral ========
 */
void Board_initGeneral(void)
{
    /*  Reset DMA + other essential peripheral initialization
     *  ASSUMED by the simplelink and driverlib libraries
     */
    PRCMCC3200MCUInit();

    /* Configure pins as specified in the current configuration */

    /*
     * ======== Enable Peripheral Clocks ========
     * Enable all clocks (because wiring can use any pin for in any mode
     * at runtime)
     */
    MAP_PRCMPeripheralClkEnable(PRCM_CAMERA, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralClkEnable(PRCM_GSPI, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralClkEnable(PRCM_I2S, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralClkEnable(PRCM_SDHOST, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA1, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA2, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA3, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);


    /* ======== UART Pin Configuration ======== */

    /* Serial */

    /*
     * Configure LaunchPad P2.9 as a UART1: UART1 TX (via USB port)
     *     device pin: 55 (UART0_TX)
     *     Wiring id : 12
     */
    MAP_PinTypeUART(PIN_55, PIN_MODE_6);

    /*
     * Configure LaunchPad P3.3 as a UART1: UART1 RX (via USB port)
     *     device pin: 57 (UART0_RX)
     *     Wiring id : 23
     */
    MAP_PinTypeUART(PIN_57, PIN_MODE_6);

    /* Serial1 */

    /*
     * Configure LaunchPad P1.4 as a UART0: UART0 TX
     *     device pin: 3 (UART0_TX)
     *     Wiring id : 4
     */
    MAP_PinTypeUART(PIN_03, PIN_MODE_7);

    /*
     * Configure LaunchPad P1.3 as a UART0: UART0 RX
     *     device pin: 4 (UART0_RX)
     *     Wiring id : 3
     */
    MAP_PinTypeUART(PIN_04, PIN_MODE_7);


    /* ======== SPI Pin Configuration ======== */

    /*
     * Configure LaunchPad P1.7 as a SPI pin: SPI CLK
     *     device pin: 5 (GSPI_CLK)
     *     Wiring id : 7
     */
    MAP_PinTypeSPI(PIN_05, PIN_MODE_7);

    /*
     * Configure LaunchPad P2.6 as a SPI pin: SPI MOSI
     *     device pin: 7 (GSPI_MOSI)
     *     Wiring id : 15
     */
    MAP_PinTypeSPI(PIN_07, PIN_MODE_7);

    /*
     * Configure LaunchPad P2.7 as a SPI pin: SPI MISO
     *     device pin: 6 (GSPI_MISO)
     *     Wiring id : 14
     */
    MAP_PinTypeSPI(PIN_06, PIN_MODE_7);


    /* ======== I2C Pin Configuration ======== */

    /*
     * Configure LaunchPad P1.9 as a I2C pin: LaunchPad Sensor Data (via I2C)
     *     device pin: 1 (I2C_SCL)
     *     Wiring id : 9
     */
    MAP_PinTypeI2C(PIN_01, PIN_MODE_1);

    /*
     * Configure LaunchPad P1.10 as a I2C pin: LaunchPad Sensor Data (via I2C)
     *     device pin: 2 (I2C_SDA)
     *     Wiring id : 10
     */
    MAP_PinTypeI2C(PIN_02, PIN_MODE_1);
}
Beispiel #9
0
//*****************************************************************************
void
PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_I2S, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_50 for MCASP0 McAXR1
    //
    MAP_PinTypeI2S(PIN_50, PIN_MODE_6);

    //
    // Configure PIN_55 for UART0 UART0_TX
    //
    MAP_PinTypeUART(PIN_55, PIN_MODE_3);

    //
    // Configure PIN_57 for UART0 UART0_RX
    //
    MAP_PinTypeUART(PIN_57, PIN_MODE_3);

    //
    // Configure PIN_63 for MCASP0 McAFSX
    //
    MAP_PinTypeI2S(PIN_63, PIN_MODE_7);

    //
    // Configure PIN_64 for MCASP0 McAXR0
    //
    MAP_PinTypeI2S(PIN_64, PIN_MODE_7);

    //
    // Configure PIN_01 for I2C0 I2C_SCL
    //
    MAP_PinTypeI2C(PIN_01, PIN_MODE_1);

    //
    // Configure PIN_02 for I2C0 I2C_SDA
    //
    MAP_PinTypeI2C(PIN_02, PIN_MODE_1);

    //
    // Configure PIN_04 for GPIOInput
    //
    MAP_PinTypeGPIO(PIN_04, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x20, GPIO_DIR_MODE_IN);

    //
    // Configure PIN_15 for GPIOInput
    //
    MAP_PinTypeGPIO(PIN_15, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA2_BASE, 0x40, GPIO_DIR_MODE_IN);

    //
    // Configure PIN_53 for MCASP0 McACLK
    //
    MAP_PinTypeI2S(PIN_53, PIN_MODE_2);
}
Beispiel #10
0
//*****************************************************************************
void
PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_CAMERA, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_I2CA0, PRCM_RUN_MODE_CLK);

    //
    // Configure PIN_55 for CAMERA0 CAM_pCLK
    //
    MAP_PinTypeCamera(PIN_55, PIN_MODE_4);

    //
    // Configure PIN_58 for CAMERA0 CAM_pDATA7
    //
    MAP_PinTypeCamera(PIN_58, PIN_MODE_4);

    //
    // Configure PIN_59 for CAMERA0 CAM_pDATA6
    //
    MAP_PinTypeCamera(PIN_59, PIN_MODE_4);

    //
    // Configure PIN_60 for CAMERA0 CAM_pDATA5
    //
    MAP_PinTypeCamera(PIN_60, PIN_MODE_4);

    //
    // Configure PIN_61 for CAMERA0 CAM_pDATA4
    //
    MAP_PinTypeCamera(PIN_61, PIN_MODE_4);

    //
    // Configure PIN_02 for CAMERA0 CAM_pXCLK
    //
    MAP_PinTypeCamera(PIN_02, PIN_MODE_4);

    //
    // Configure PIN_03 for CAMERA0 CAM_vS
    //
    MAP_PinTypeCamera(PIN_03, PIN_MODE_4);

    //
    // Configure PIN_04 for CAMERA0 CAM_hS
    //
    MAP_PinTypeCamera(PIN_04, PIN_MODE_4);

    //
    // Configure PIN_05 for CAMERA0 CAM_pDATA8
    //
    MAP_PinTypeCamera(PIN_05, PIN_MODE_4);

    //
    // Configure PIN_06 for CAMERA0 CAM_pDATA9
    //
    MAP_PinTypeCamera(PIN_06, PIN_MODE_4);

    //
    // Configure PIN_07 for CAMERA0 CAM_pDATA10
    //
    MAP_PinTypeCamera(PIN_07, PIN_MODE_4);

    //
    // Configure PIN_08 for CAMERA0 CAM_pDATA11
    //
    MAP_PinTypeCamera(PIN_08, PIN_MODE_4);

    //
    // Configure PIN_16 for I2C0 I2C_SCL
    //
    MAP_PinTypeI2C(PIN_16, PIN_MODE_9);

    //
    // Configure PIN_17 for I2C0 I2C_SDA
    //
    MAP_PinTypeI2C(PIN_17, PIN_MODE_9);
}