//*****************************************************************************
void PinMuxConfig(void)
{
	//
    // Enable Peripheral Clocks 
    //
	MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);

	//
    // Configure PIN_07 for UART1 UART1_TX
    //
	MAP_PinTypeUART(PIN_07, PIN_MODE_5);

	//
    // Configure PIN_08 for UART1 UART1_RX
    //
	MAP_PinTypeUART(PIN_08, PIN_MODE_5);

	//
    // 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_64 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);

	//
    // Configure PIN_01 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);

	//
    // Configure PIN_02 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);

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

	//
    // Configure PIN_15 for GPIO Input
    //
	MAP_PinTypeGPIO(PIN_15, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA2_BASE, 0x40, GPIO_DIR_MODE_IN);
}
Example #2
0
File: pinmux.c Project: dlugaz/All
//*****************************************************************************
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);
}
Example #3
0
//*****************************************************************************
void
PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, 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_64 for GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);
}
Example #4
0
void HardwareSerial::begin(unsigned long baud)
{
	baudRate = baud;

	/* Set the UART to interrupt whenever the TX FIFO is almost empty or
	 * when any character is received. */
	//MAP_UARTFIFOLevelSet(UART_BASE, UART_FIFO_TX7_8, UART_FIFO_RX7_8);

	/* Initialize the UART. */
//	UARTClockSourceSet(UART_BASE, UART_CLOCK_SYSTEM);
	MAP_PRCMPeripheralReset(g_ulUARTPeriph[uartModule]);

	MAP_PRCMPeripheralClkEnable(g_ulUARTPeriph[uartModule], PRCM_RUN_MODE_CLK);

	MAP_PinTypeUART(g_ulUARTConfig[uartModule][0], PIN_MODE_3);
	MAP_PinTypeUART(g_ulUARTConfig[uartModule][1], PIN_MODE_3);

	MAP_UARTConfigSetExpClk(UART_BASE, 80000000, baudRate,
				(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
				UART_CONFIG_WLEN_8));

	flushAll();
	MAP_IntEnable(g_ulUARTInt[uartModule]);

	/* Enable the UART operation. */
	MAP_UARTEnable(UART_BASE);

	MAP_UARTIntEnable(UART_BASE, UART_INT_RT | UART_INT_TX);
}
Example #5
0
int main() {
  MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]);
  MAP_IntEnable(FAULT_SYSTICK);
  MAP_IntMasterEnable();
  PRCMCC3200MCUInit();

  cc3200_leds_init();

  /* 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_UARTFIFODisable(CONSOLE_UART);

  setvbuf(stdout, NULL, _IONBF, 0);
  setvbuf(stderr, NULL, _IONBF, 0);

  VStartSimpleLinkSpawnTask(8);
  osi_TaskCreate(v7_task, (const signed char *) "v7", V7_STACK_SIZE + 256, NULL,
                 3, NULL);
  osi_TaskCreate(blinkenlights_task, (const signed char *) "blink", 256, NULL,
                 9, NULL);
  osi_start();

  return 0;
}
Example #6
0
/*
 *  ======== Board_openUART ========
 *  Initialize the UART driver.
 *  Initialize the UART port's pins.
 *  Open the UART port.
 */
UART_Handle  Board_openUART(UInt uartPortIndex, UART_Params *uartParams)
{
    /* Initialize the UART driver */
    /* By design, UART_init() is idempotent */
    UART_init();

    /* initialize the pins associated with the respective UART */
    switch(uartPortIndex) {
        case 0:
            /* Serial */
            /* enable UART1 clock */
            MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);

            /*
             * Configure LaunchPad P2.9 as a UART1: UART1 TX (via USB port)
             *     device pin: 55 (UART1_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 (UART1_RX)
             *     Wiring id : 23
             */
            MAP_PinTypeUART(PIN_57, PIN_MODE_6);
            break;

        case 1:
            /* Serial1 */
            /* enable UART0 clock */
            MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);

            /*
             * 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);
            break;

        default:
            return (NULL);
    }

    /* open the UART */
    return (UART_open(uartPortIndex, uartParams));
}
Example #7
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);
}
Example #8
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;
}
Example #9
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_GPIOA2, PRCM_RUN_MODE_CLK);

    MAP_PRCMPeripheralClkEnable(PRCM_TIMERA3, 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_15 for GPIO Input
    //
	MAP_PinTypeGPIO(PIN_15, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA2_BASE, 0x40, GPIO_DIR_MODE_IN);


    //
    // Configure PIN_02 for TIMERPWM7 GT_PWM07
    //
    MAP_PinTypeTimer(PIN_02, PIN_MODE_3);
}
Example #10
0
Uart0::Error Uart0::init_pins() {
  /* Tx */
  if ((mode == kModeDuplex) || (mode == kModeTxOnly))
    MAP_PinTypeUART(PIN_55, PIN_MODE_3);

  /*Rx*/
  if ((mode == kModeDuplex) || (mode == kModeRxOnly))
    MAP_PinTypeUART(PIN_57, PIN_MODE_3);

  if (flow_control == kFlowControlHardware) {
    /* CTS */
    MAP_PinTypeUART(PIN_50, PIN_MODE_12);
    /*RTS*/
    MAP_PinTypeUART(PIN_52, PIN_MODE_6);
  }
  return kOK;
}
Example #11
0
static void BoardInit()
{
    MAP_IntVTableBaseSet((unsigned long)&g_pfnVectors[0]);

    MAP_IntMasterEnable();
    MAP_IntEnable(FAULT_SYSTICK);

    PRCMCC3200MCUInit();

    UDMAInit();

    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    MAP_PinTypeUART(PIN_55, PIN_MODE_3);
    MAP_PinTypeUART(PIN_57, PIN_MODE_3);

    InitTerm();
}
Example #12
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);
}
Example #13
0
//*****************************************************************************
void
PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GSPI, 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_05 for SPI0 GSPI_CLK
    //
    MAP_PinTypeSPI(PIN_05, PIN_MODE_7);

    //
    // Configure PIN_06 for SPI0 GSPI_MISO
    //
    MAP_PinTypeSPI(PIN_06, PIN_MODE_7);

    //
    // Configure PIN_07 for SPI0 GSPI_MOSI
    //
    MAP_PinTypeSPI(PIN_07, PIN_MODE_7);

    //
    // Configure PIN_08 for SPI0 GSPI_CS
    //
    MAP_PinTypeSPI(PIN_08, PIN_MODE_7);
}
Example #14
0
void cc32xx_uart_early_init(int uart_no, int baud_rate) {
  if (uart_no < 0) return;
  uint32_t base = cc32xx_uart_get_base(uart_no);
  uint32_t periph;
  if (uart_no == 0) {
    periph = PRCM_UARTA0;
    MAP_PinTypeUART(PIN_55, PIN_MODE_3); /* UART0_TX */
    MAP_PinTypeUART(PIN_57, PIN_MODE_3); /* UART0_RX */
  } else if (uart_no == 1) {
    periph = PRCM_UARTA1;
    MAP_PinTypeUART(PIN_07, PIN_MODE_5); /* UART1_TX */
    MAP_PinTypeUART(PIN_08, PIN_MODE_5); /* UART1_RX */
  } else {
    return;
  }
  MAP_PRCMPeripheralClkEnable(periph, PRCM_RUN_MODE_CLK);
  MAP_UARTConfigSetExpClk(
      base, MAP_PRCMPeripheralClockGet(periph), baud_rate,
      UART_CONFIG_WLEN_8 | UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE);
  MAP_UARTFIFODisable(base);
  MAP_UARTIntDisable(base, ~0); /* Start with ints disabled. */
}
Example #15
0
int main()
{
  MAP_IntVTableBaseSet((unsigned long)vectors);
  MAP_IntMasterEnable();
  MAP_IntEnable(FAULT_SYSTICK);
  PRCMCC3200MCUInit();
#ifdef UART_LOG
  MAP_PRCMPeripheralClkEnable(PRCM_UART_TERM, PRCM_RUN_MODE_CLK);
  MAP_PinTypeUART(PIN_TERM_TX, PIN_TERM_TX_MODE);
  MAP_PinTypeUART(PIN_TERM_RX, PIN_TERM_RX_MODE);
  MAP_UARTConfigSetExpClk(UART_TERM,
                          MAP_PRCMPeripheralClockGet(PRCM_UART_TERM),
                          115200,
                          (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |UART_CONFIG_PAR_NONE));
#endif

  MonitorLoop();

  asm(" BKPT");
  while ( 1 );

  return 0;
}
Example #16
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_GPIOA3, PRCM_RUN_MODE_CLK);

#if defined(P_RELAY_BOARD)
	MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
#endif // P_RELAY_BOARD

    //
    // 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_50 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_50, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA0_BASE, 0x1, GPIO_DIR_MODE_OUT);

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

	//
    // Configure PIN_53 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_53, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA3_BASE, 0x40, GPIO_DIR_MODE_OUT);

#if defined(P_RELAY_BOARD)
	//
    // Configure PIN_59 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_59, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA0_BASE, 0x10, GPIO_DIR_MODE_OUT);

	//
    // Configure PIN_61 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_61, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA0_BASE, 0x40, GPIO_DIR_MODE_OUT);

	//
    // Configure PIN_62 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_62, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA0_BASE, 0x80, GPIO_DIR_MODE_OUT);

	//
    // Configure PIN_64 for GPIO Output
    //
	MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);
#endif // P_RELAY_BOARD
}
//*****************************************************************************
//
//! Mandatory MCU Initialization Routine
//!
//! \param  None
//!
//! \return None
//
//*****************************************************************************
void MCUInit(void)
{
    unsigned long ulRegVal;

    //
    // DIG DCDC NFET SEL and COT mode disable
    //
    HWREG(0x4402F010) = 0x30031820;
    HWREG(0x4402F00C) = 0x04000000;

    UtilsDelay(32000);

    //
    // ANA DCDC clock config
    //
    HWREG(0x4402F11C) = 0x099;
    HWREG(0x4402F11C) = 0x0AA;
    HWREG(0x4402F11C) = 0x1AA;

    //
    // PA DCDC clock config
    //
    HWREG(0x4402F124) = 0x099;
    HWREG(0x4402F124) = 0x0AA;
    HWREG(0x4402F124) = 0x1AA;

    //
    // Enable RTC
    //
    if(MAP_PRCMSysResetCauseGet()== PRCM_POWER_ON)
    {
        HWREG(0x4402F804) = 0x1;
    }

    //
    // TD Flash timing configurations in case of MCU WDT reset
    //

    if((HWREG(0x4402D00C) & 0xFF) == 0x00000005)
    {
        HWREG(0x400F707C) |= 0x01840082;
        HWREG(0x400F70C4)= 0x1;
        HWREG(0x400F70C4)= 0x0;
    }

    //
    // JTAG override for I2C in SWD mode
    //
    if(((HWREG(0x4402F0C8) & 0xFF) == 0x2))
    {
        MAP_PinModeSet(PIN_19,PIN_MODE_2);
        MAP_PinModeSet(PIN_20,PIN_MODE_2);
        HWREG(0x4402E184) |= 0x1;
    }

    //
    // Take I2C semaphore,##IMPROTANT:REMOVE IN PG1.32 DEVICES##
    //
    ulRegVal = HWREG(COMMON_REG_BASE + COMMON_REG_O_I2C_Properties_Register);
    ulRegVal = (ulRegVal & ~0x3) | 0x1;
    HWREG(COMMON_REG_BASE + COMMON_REG_O_I2C_Properties_Register) = ulRegVal;

    //
    // Take GPIO semaphore##IMPROTANT:REMOVE IN PG1.32 DEVICES##
    //
    ulRegVal = HWREG(COMMON_REG_BASE + COMMON_REG_O_GPIO_properties_register);
    ulRegVal = (ulRegVal & ~0x3FF) | 0x155;
    HWREG(COMMON_REG_BASE + COMMON_REG_O_GPIO_properties_register) = ulRegVal;

    //
    // Change UART pins(55,57) mode to PIN_MODE_0 if they are in PIN_MODE_1(NWP mode)
    //
    if((MAP_PinModeGet(PIN_55)) == PIN_MODE_1)
    {
        MAP_PinModeSet(PIN_55,PIN_MODE_0);
    }
    if((MAP_PinModeGet(PIN_57)) == PIN_MODE_1)
    {
        MAP_PinModeSet(PIN_57,PIN_MODE_0);
    }
    
     //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, 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);
    
    InitTerm();         //set the parameters of uart0

}
Example #18
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_SDHOST, 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 GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_02 for GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);

    //
	// Configure PIN_50 for GPIO Input (TILT)
	//
	MAP_PinTypeGPIO(PIN_50, PIN_MODE_0, false);
	MAP_GPIODirModeSet(GPIOA0_BASE, 0x1, GPIO_DIR_MODE_IN);


    //
    // Configure PIN_64 for SDHOST0 SDHost_D0
    //
    //MAP_PinTypeSDHost(PIN_64, PIN_MODE_6);

    //
    // Configure PIN_01 for SDHOST0 SDHost_CLK
    //
    //MAP_PinTypeSDHost(PIN_01, PIN_MODE_6);

    //
    // Configure PIN_02 for SDHOST0 SDHost_CMD
    //
    //MAP_PinTypeSDHost(PIN_02, PIN_MODE_6);
}
Example #19
0
bool mgos_uart_hal_configure(struct mgos_uart_state *us,
                             const struct mgos_uart_config *cfg) {
  uint32_t base = cc32xx_uart_get_base(us->uart_no);
  if (us->uart_no == 0 && (cfg->tx_fc_type == MGOS_UART_FC_HW ||
                           cfg->rx_fc_type == MGOS_UART_FC_HW)) {
    /* No FC on UART0, according to the TRM. */
    return false;
  }
  MAP_UARTIntDisable(base, ~0);
  uint32_t periph = (us->uart_no == 0 ? PRCM_UARTA0 : PRCM_UARTA1);
  uint32_t data_cfg = 0;
  switch (cfg->num_data_bits) {
    case 5:
      data_cfg |= UART_CONFIG_WLEN_5;
      break;
    case 6:
      data_cfg |= UART_CONFIG_WLEN_6;
      break;
    case 7:
      data_cfg |= UART_CONFIG_WLEN_7;
      break;
    case 8:
      data_cfg |= UART_CONFIG_WLEN_8;
      break;
    default:
      return false;
  }

  switch (cfg->parity) {
    case MGOS_UART_PARITY_NONE:
      data_cfg |= UART_CONFIG_PAR_NONE;
      break;
    case MGOS_UART_PARITY_EVEN:
      data_cfg |= UART_CONFIG_PAR_EVEN;
      break;
    case MGOS_UART_PARITY_ODD:
      data_cfg |= UART_CONFIG_PAR_ODD;
      break;
  }

  switch (cfg->stop_bits) {
    case MGOS_UART_STOP_BITS_1:
      data_cfg |= UART_CONFIG_STOP_ONE;
      break;
    case MGOS_UART_STOP_BITS_1_5:
      return false; /* Not supported */
    case MGOS_UART_STOP_BITS_2:
      data_cfg |= UART_CONFIG_STOP_TWO;
      break;
  }

  MAP_UARTConfigSetExpClk(base, MAP_PRCMPeripheralClockGet(periph),
                          cfg->baud_rate, data_cfg);

  if (cfg->tx_fc_type == MGOS_UART_FC_HW ||
      cfg->rx_fc_type == MGOS_UART_FC_HW) {
    /* Note: only UART1 */
    uint32_t ctl = HWREG(base + UART_O_CTL);
    if (cfg->tx_fc_type == MGOS_UART_FC_HW) {
      ctl |= UART_CTL_CTSEN;
      MAP_PinTypeUART(PIN_61, PIN_MODE_3); /* UART1_CTS */
    }
    if (cfg->rx_fc_type == MGOS_UART_FC_HW) {
      ctl |= UART_CTL_RTSEN;
      MAP_PinTypeUART(PIN_62, PIN_MODE_3); /* UART1_RTS */
    }
    HWREG(base + UART_O_CTL) = ctl;
  }
  MAP_UARTFIFOLevelSet(base, UART_FIFO_TX1_8, UART_FIFO_RX4_8);
  MAP_UARTFIFOEnable(base);
  return true;
}
Example #20
0
int main(void) {
  MAP_IntVTableBaseSet((unsigned long) &int_vectors[0]);
  MAP_IntMasterEnable();
  PRCMCC3200MCUInit();

/* Console UART init. */
#ifndef NO_DEBUG
  MAP_PRCMPeripheralClkEnable(DEBUG_UART_PERIPH, PRCM_RUN_MODE_CLK);
#if MIOT_DEBUG_UART == 0
  MAP_PinTypeUART(PIN_55, PIN_MODE_3); /* UART0_TX */
  MAP_PinTypeUART(PIN_57, PIN_MODE_3); /* UART0_RX */
#else
  MAP_PinTypeUART(PIN_07, PIN_MODE_5); /* UART1_TX */
  MAP_PinTypeUART(PIN_08, PIN_MODE_5); /* UART1_RX */
#endif
  MAP_UARTConfigSetExpClk(
      DEBUG_UART_BASE, MAP_PRCMPeripheralClockGet(DEBUG_UART_PERIPH),
      MIOT_DEBUG_UART_BAUD_RATE,
      (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
  MAP_UARTFIFOLevelSet(DEBUG_UART_BASE, UART_FIFO_TX1_8, UART_FIFO_RX4_8);
  MAP_UARTFIFODisable(DEBUG_UART_BASE);
#endif

  dbg_puts("\r\n\n");

  if (sl_Start(NULL, NULL, NULL) < 0) abort();
  dbg_putc('S');

  int cidx = get_active_boot_cfg_idx();
  if (cidx < 0) abort();
  dbg_putc('0' + cidx);
  struct boot_cfg cfg;
  if (read_boot_cfg(cidx, &cfg) < 0) abort();

  dbg_puts(cfg.app_image_file);
  dbg_putc('@');
  print_addr(cfg.app_load_addr);

  /*
   * Zero memory before loading.
   * This should provide proper initialisation for BSS, wherever it is.
   */
  uint32_t *pstart = (uint32_t *) 0x20000000;
  uint32_t *pend = (&_text_start - 0x100 /* our stack */);
  for (uint32_t *p = pstart; p < pend; p++) *p = 0;

  if (load_image(cfg.app_image_file, (_u8 *) cfg.app_load_addr) != 0) {
    abort();
  }

  dbg_putc('.');

  sl_Stop(0);
  print_addr(*(((uint32_t *) cfg.app_load_addr) + 1));
  dbg_puts("\r\n\n");

  MAP_IntMasterDisable();
  MAP_IntVTableBaseSet(cfg.app_load_addr);

  run(cfg.app_load_addr); /* Does not return. */

  abort();

  return 0; /* not reached */
}
Example #21
0
//*****************************************************************************
//ESSENTIAL
void
PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_PRCMPeripheralClkEnable(PRCM_ADC, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA1, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_GPIOA2, PRCM_RUN_MODE_CLK);
    MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);

    //
    // 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 GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_02 for GPIOOutput
    //
    MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_03 for GPIO Output
    //
    MAP_PinTypeGPIO(PIN_03, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x10, GPIO_DIR_MODE_OUT);

    //
    // 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_58 for ADC0 ADC_CH1
    //
    MAP_PinTypeADC(PIN_58, PIN_MODE_255);

    //
    // Configure PIN_59 for ADC0 ADC_CH2
    //
    MAP_PinTypeADC(PIN_59, PIN_MODE_255);

    //
    // Configure PIN_60 for ADC0 ADC_CH3
    //
    MAP_PinTypeADC(PIN_60, PIN_MODE_255);

    //
    // 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);
}
//*****************************************************************************
void PinMuxConfig(void)
{
    //
    // Enable Peripheral Clocks 
    //
    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);

    // 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);

#ifdef BOARD_LAUNCHPAD
    //
    // Configure PIN_06 for GPIO Output (TDI)
    //
    MAP_PinTypeGPIO(PIN_06, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x80, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_08 for GPIO Output (TMS)
    //
    MAP_PinTypeGPIO(PIN_08, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA2_BASE, 0x2, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_18 for GPIO Output (TCK)
    //
    MAP_PinTypeGPIO(PIN_18, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA3_BASE, 0x10, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_15 for GPIO Input (TDO)
    //
    MAP_PinTypeGPIO(PIN_15, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA3_BASE, 0x2, GPIO_DIR_MODE_IN);

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

    //
    // Configure PIN_64 for GPIO Output (red LED)
    //
    MAP_PinTypeGPIO(PIN_64, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x2, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_01 for GPIO Output (yellow LED)
    //
    MAP_PinTypeGPIO(PIN_01, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x4, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_02 for GPIO Output (green LED)
    //
    MAP_PinTypeGPIO(PIN_02, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x8, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_07 for GPIO Output (nRST)
    //
    MAP_PinTypeGPIO(PIN_07, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA2_BASE, 0x1, GPIO_DIR_MODE_OUT);
#endif

#ifdef BOARD_RBL_WIFIMINI

    //
    // Configure PIN_03 for GPIO Input (TDO)
    //
    MAP_PinTypeGPIO(PIN_03, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x10, GPIO_DIR_MODE_IN);

    //
    // Configure PIN_05 for GPIO14 Output (TCK)
    //
    MAP_PinTypeGPIO(PIN_05, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x40, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_06 for GPIO15 Output (TMS)
    //
    MAP_PinTypeGPIO(PIN_06, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x80, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_07 for GPIO16 Output (TDI)
    //
    MAP_PinTypeGPIO(PIN_07, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA2_BASE, 0x1, GPIO_DIR_MODE_OUT);

    //
    // Configure PIN_53 for GPIO Output (LED)
    //
    MAP_PinTypeGPIO(PIN_53, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA3_BASE, 0x40, GPIO_DIR_MODE_OUT);

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

    //
    // Configure PIN_04 for GPIO Output (LOW for APSEL)
    //
    MAP_PinTypeGPIO(PIN_04, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA1_BASE, 0x20, GPIO_DIR_MODE_OUT);
    MAP_GPIOPinWrite(GPIOA1_BASE, 0x20, 0);

    //
    // Configure PIN_08 for GPIO Output (HIGH for APSEL)
    //
    MAP_PinTypeGPIO(PIN_08, PIN_MODE_0, false);
    MAP_GPIODirModeSet(GPIOA2_BASE, 0x2, GPIO_DIR_MODE_OUT);
    MAP_GPIOPinWrite(GPIOA2_BASE, 0x2, 1);

#endif
}
Example #23
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);
}
Example #24
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);
}
Example #25
0
static void uart_int() {
    int c = UARTCharGet(CONSOLE_UART);
    struct prompt_event pe = {.type = PROMPT_CHAR_EVENT, .data = (void *) c};
    osi_MsgQWrite(&s_v7_q, &pe, OSI_NO_WAIT);
    MAP_UARTIntClear(CONSOLE_UART, UART_INT_RX);
}

void sj_prompt_init_hal(struct v7 *v7) {
    (void) v7;
}

static void v7_task(void *arg) {
    struct v7 *v7 = s_v7;
    printf("\n\nSmart.JS for CC3200\n");

    osi_MsgQCreate(&s_v7_q, "V7", sizeof(struct prompt_event), 32 /* len */);
    osi_InterruptRegister(CONSOLE_UART_INT, uart_int, INT_PRIORITY_LVL_1);
    MAP_UARTIntEnable(CONSOLE_UART, UART_INT_RX);
    sl_Start(NULL, NULL, NULL);

    v7 = s_v7 = init_v7(&v7);
    sj_init_timers(v7);
    sj_init_v7_ext(v7);
    init_wifi(v7);
    if (init_fs(v7) != 0) {
        fprintf(stderr, "FS initialization failed.\n");
    }
    mongoose_init();
    sj_init_http(v7);
    init_i2cjs(v7);

    /* Common config infrastructure. Mongoose & v7 must be initialized. */
    init_device(v7);

    v7_val_t res;
    if (v7_exec_file(v7, "sys_init.js", &res) != V7_OK) {
        fprintf(stderr, "Error: ");
        v7_fprint(stderr, v7, res);
    }
    sj_prompt_init(v7);

    while (1) {
        struct prompt_event pe;
        mongoose_poll(MONGOOSE_POLL_LENGTH_MS);
        if (osi_MsgQRead(&s_v7_q, &pe, V7_POLL_LENGTH_MS) != OSI_OK) continue;
        switch (pe.type) {
        case PROMPT_CHAR_EVENT: {
            sj_prompt_process_char((char) ((int) pe.data));
            break;
        }
        case V7_INVOKE_EVENT: {
            struct v7_invoke_event_data *ied =
                (struct v7_invoke_event_data *) pe.data;
            _sj_invoke_cb(v7, ied->func, ied->this_obj, ied->args);
            v7_disown(v7, &ied->args);
            v7_disown(v7, &ied->this_obj);
            v7_disown(v7, &ied->func);
            free(ied);
            break;
        }
        }
    }
}

/* Int vector table, defined in startup_gcc.c */
extern void (*const g_pfnVectors[])(void);

void device_reboot(void) {
    sj_system_restart();
}

int main() {
    MAP_IntVTableBaseSet((unsigned long) &g_pfnVectors[0]);
    MAP_IntEnable(FAULT_SYSTICK);
    MAP_IntMasterEnable();
    PRCMCC3200MCUInit();

    cc3200_leds_init();

    /* 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_UARTFIFODisable(CONSOLE_UART);

    setvbuf(stdout, NULL, _IONBF, 0);
    setvbuf(stderr, NULL, _IONBF, 0);

    VStartSimpleLinkSpawnTask(8);
    osi_TaskCreate(v7_task, (const signed char *) "v7", V7_STACK_SIZE + 256, NULL,
                   3, NULL);
    osi_TaskCreate(blinkenlights_task, (const signed char *) "blink", 256, NULL,
                   9, NULL);
    osi_start();

    return 0;
}