Exemple #1
0
void configure_pin(struct header_pin *pin) {
  if(pin->config == CONFIG_INPUT) {
    MAP_GPIOPinTypeGPIOInput(pin->base, pin->pin);
  } else if( pin->config == CONFIG_OUTPUT) {
    MAP_GPIOPinTypeGPIOOutput(pin->base, pin->pin);
  }
}
Exemple #2
0
static void enc28j60_comm_init(void) {
  MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
  MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
  MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, ENC_CS);
  MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, ENC_INT);

  MAP_GPIOPinWrite(ENC_CS_PORT, ENC_CS, ENC_CS);
}
Exemple #3
0
    // Pin config
    virtual void PinSetMode(MicroFlo::PinId pin, IO::PinMode mode) {

        MAP_SysCtlPeripheralEnable(peripheral(pin));
        if (mode == IO::InputPin) {
            MAP_GPIOPinTypeGPIOInput(portBase(pin), pinMask(pin));
        } else if (mode == IO::OutputPin) {
            MAP_GPIOPinTypeGPIOOutput(portBase(pin), pinMask(pin));
        } else {
            MICROFLO_DEBUG(debug, DebugLevelError, DebugIoOperationNotImplemented);
        }
    }
Exemple #4
0
pio_type platform_pio_op( unsigned port, pio_type pinmask, int op )
{
    pio_type retval = 1, base = pio_base[ port ];

    switch( op )
    {
    case PLATFORM_IO_PORT_SET_VALUE:
        MAP_GPIOPinWrite( base, 0xFF, pinmask );
        break;

    case PLATFORM_IO_PIN_SET:
        MAP_GPIOPinWrite( base, pinmask, pinmask );
        break;

    case PLATFORM_IO_PIN_CLEAR:
        MAP_GPIOPinWrite( base, pinmask, 0 );
        break;

    case PLATFORM_IO_PORT_DIR_INPUT:
        pinmask = 0xFF;
    case PLATFORM_IO_PIN_DIR_INPUT:
        MAP_GPIOPinTypeGPIOInput( base, pinmask );
        break;

    case PLATFORM_IO_PORT_DIR_OUTPUT:
        pinmask = 0xFF;
    case PLATFORM_IO_PIN_DIR_OUTPUT:
        MAP_GPIOPinTypeGPIOOutput( base, pinmask );
        break;

    case PLATFORM_IO_PORT_GET_VALUE:
        retval = MAP_GPIOPinRead( base, 0xFF );
        break;

    case PLATFORM_IO_PIN_GET:
        retval = MAP_GPIOPinRead( base, pinmask ) ? 1 : 0;
        break;

    case PLATFORM_IO_PIN_PULLUP:
    case PLATFORM_IO_PIN_PULLDOWN:
        MAP_GPIOPadConfigSet( base, pinmask, GPIO_STRENGTH_8MA, op == PLATFORM_IO_PIN_PULLUP ? GPIO_PIN_TYPE_STD_WPU : GPIO_PIN_TYPE_STD_WPD );
        break;

    case PLATFORM_IO_PIN_NOPULL:
        MAP_GPIOPadConfigSet( base, pinmask, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD );
        break;

    default:
        retval = 0;
        break;
    }
    return retval;
}
Exemple #5
0
void gpio_init(int pin, enum gpio_mode mode, int value)
{
	uint32_t base = TO_BASE(pin);
	pin = 1 << (pin & 0x0F);

	switch (mode) {
		case GPIO_OUTPUT:
			MAP_GPIOPinTypeGPIOOutput(base, pin);
			gpio_set(pin, value);
			break;
		case GPIO_OUTPUT_SLOW:
			MAP_GPIOPinTypeGPIOOutput(base, pin);
			MAP_GPIOPadConfigSet(base, pin, GPIO_STRENGTH_8MA_SC,
			    GPIO_PIN_TYPE_STD);
			gpio_set(pin, value);
			break;
		case GPIO_INPUT:
			MAP_GPIOPinTypeGPIOInput(base, pin);
			break;
		case GPIO_INPUT_PD:
			MAP_GPIOPinTypeGPIOInput(base, pin);
			MAP_GPIOPadConfigSet(base, pin, GPIO_STRENGTH_8MA,
			    GPIO_PIN_TYPE_STD_WPD);
			break;
		case GPIO_INPUT_PU:
			MAP_GPIOPinTypeGPIOInput(base, pin);
			MAP_GPIOPadConfigSet(base, pin, GPIO_STRENGTH_8MA,
			    GPIO_PIN_TYPE_STD_WPU);
			break;
		case GPIO_ANALOG:
			MAP_GPIOPinTypeGPIOInput(base, pin);
			MAP_GPIOPadConfigSet(base, pin, GPIO_STRENGTH_8MA,
			    GPIO_PIN_TYPE_ANALOG);
			break;
	}
}
Exemple #6
0
static void
enc28j60_comm_init(void) {
  MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
  MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
  MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
  MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, ENC_CS | ENC_RESET);
  MAP_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, SRAM_CS);
//  MAP_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, ENC_CS | ENC_RESET | SRAM_CS);
  MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, ENC_INT);

  MAP_GPIOPinWrite(GPIO_PORTB_BASE, ENC_RESET, 0);
  MAP_GPIOPinWrite(ENC_CS_PORT, ENC_CS, ENC_CS);
  MAP_GPIOPinWrite(GPIO_PORTA_BASE, SRAM_CS, SRAM_CS);
  SysCtlDelay(((SysCtlClockGet() / 3) / 10)); //100ms delay
  MAP_GPIOPinWrite(GPIO_PORTB_BASE, ENC_RESET, ENC_RESET);
}
//*****************************************************************************
//
// Initialization function for the LXD display. This turns on the backlight
// and sets the correct RGB mode.
//
//*****************************************************************************
void
InitLXDAndFormike(uint32_t ui32SysClk)
{
    //
    // Convert PT2 & 3 back to a GPIO output (they were LCDDATA18/19)
    //
    HWREG(GPIO_PORTT_BASE + GPIO_O_PCTL) &= 0xFFFF00FF;
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTT_BASE, GPIO_PIN_2 | GPIO_PIN_3);

    //
    // Convert PS0 and 1 back to GPIO outputs (they were LCDDATA20/21)
    //
    HWREG(GPIO_PORTS_BASE + GPIO_O_PCTL) &= 0xFFFFFF00;
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTS_BASE, GPIO_PIN_1 | GPIO_PIN_0);

    //
    // Drive PS0/1 to set the display TL to BR scanning direction.
    //
    MAP_GPIOPinWrite(GPIO_PORTS_BASE, GPIO_PIN_1 | GPIO_PIN_0, GPIO_PIN_0);

    //
    // Write PT2 high to turn on the backlight.
    //
    MAP_GPIOPinWrite(GPIO_PORTT_BASE, GPIO_PIN_2, GPIO_PIN_2);

    //
    // Turn OE/DE off
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTJ_BASE, GPIO_PIN_6);

    //
    // Write PT3 low to set the display into RGB mode.
    //
    MAP_GPIOPinWrite(GPIO_PORTT_BASE, GPIO_PIN_3, 0);

    //
    // Write PT3 low to set the display into RGB mode.
    //
    MAP_GPIOPinWrite(GPIO_PORTT_BASE, GPIO_PIN_3, 0);
}
Exemple #8
0
int main()
{
	//
	// Enable lazy stacking for interrupt handlers.  This allows floating-point
	// instructions to be used within interrupt handlers, but at the expense of
	// extra stack usage.
	//
	MAP_FPUEnable();
	MAP_FPULazyStackingEnable();

	//
	// Set the clocking to run from the PLL at 50MHZ, change to SYSCTL_SYSDIV_2_5 for 80MHz if neeeded
	//
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
	MAP_IntMasterDisable();

	//
	// Initialize the SW2 button
	//
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	//
	// Unlock PF0 so we can change it to a GPIO input
	// Once we have enabled (unlocked) the commit register then re-lock it
	// to prevent further changes.  PF0 is muxed with NMI thus a special case.
	//
	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= 0x01;
	HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = 0;
	MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);
	MAP_GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA , GPIO_PIN_TYPE_STD_WPU);

	//
	// Initialize the communication layer with a default UART setting
	//
	AbstractComm * comm = NULL;
	AbstractComm * uart_comm = new UARTComm();
	purpinsComm communication(uart_comm);

	//
	// Initialize the robot object
	//
	purpinsRobot purpins;

	//
	// Initialize the EEPROM
	//
	purpinsSettings settings;

	//
	// Initialize the MPU6050-based IMU
	//
	mpudata_t mpu;
	//unsigned long sample_rate = 10 ;
	//mpu9150_init(0, sample_rate, 0);
	memset(&mpu, 0, sizeof(mpudata_t));

	//
	// Get the current processor clock frequency.
	//
	ulClockMS = MAP_SysCtlClockGet() / (3 * 1000);
	//unsigned long loop_delay = (1000 / sample_rate) - 2;

	//
	// Configure SysTick to occur 1000 times per second
	//
	MAP_SysTickPeriodSet(MAP_SysCtlClockGet() / SYSTICKS_PER_SECOND);
	MAP_SysTickIntEnable();
	MAP_SysTickEnable();

	MAP_IntMasterEnable();

	//
	// Load the settings from EEPROM
	//
	// Load the robot's ID
	settings.get(PP_SETTING_ID, &id, sizeof(uint32_t));
	// Load the motors' PID gains
	settings.get(PP_SETTING_LEFT_PID, purpins.leftPIDGains(), sizeof(PIDGains));
	settings.get(PP_SETTING_RIGHT_PID, purpins.rightPIDGains(), sizeof(PIDGains));
	// Load the communication type
	uint32_t comm_type;
	settings.get(PP_SETTING_COMM_TYPE, &comm_type, sizeof(uint32_t));
	// Holding SW2 at startup forces USB Comm
	if(comm_type != PP_COMM_TYPE_USB && MAP_GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_0) == 1)
	{
		if(comm_type == PP_COMM_TYPE_CC3000)
		{
			comm = new WiFiComm();
			// Load network and server settings
			settings.get(PP_SETTING_NETWORK_DATA, (static_cast<WiFiComm*>(comm))->network(), sizeof(Network));
			settings.get(PP_SETTING_SERVER_DATA, (static_cast<WiFiComm*>(comm))->server(), sizeof(Server));
			// Set WiFiComm as the underlying communication layer
			communication.setCommLayer(comm);
		}
		else if(comm_type == PP_COMM_TYPE_ESP8266)
		{
			// TODO
		}
		else if(comm_type == PP_COMM_TYPE_XBEE)
		{
			// TODO
		}
	}

	//
	// Communication variables and stuff
	//
	uint8_t sensors_pack[SENSORS_PACK_SIZE];
	bool send_pack = false;
	unsigned long sensor_streaming_millis = 0;
	unsigned long last_millis = millis();

	uint8_t data[SERIAL_BUFFER_SIZE];
	size_t data_size;
	uint8_t action;

	//
	// Main loop, just managing communications
	//
	while(1)
	{
		//
		// Check for a new action
		//
		action = communication.getMsg(data, data_size);

		// If we got an action...
		if(action > 0)
		{
			// Process it!!!
			if(action == PP_ACTION_GET_VERSION)
			{
				uint8_t version = VERSION;
				communication.sendMsg(PP_ACTION_GET_VERSION, (void*)(&version), 1);
			}
			else if(action == PP_ACTION_DRIVE)
			{
				RobotSpeed speed;
				memcpy(&speed, data, sizeof(speed));
				purpins.setSpeed(&speed);
				communication.sendAck(PP_ACTION_DRIVE);
			}
			else if(action == PP_ACTION_DRIVE_MOTORS)
			{
				MotorSpeeds motor_speeds;
				memcpy(&motor_speeds, data, sizeof(motor_speeds));
				purpins.setMotorSpeeds(&motor_speeds);
				communication.sendAck(PP_ACTION_DRIVE_MOTORS);
			}
			else if(action == PP_ACTION_DRIVE_PWM)
			{
				MotorPWMs motor_pwms;
				memcpy(&motor_pwms, data, sizeof(motor_pwms));
				purpins.setPWM(&motor_pwms);
				communication.sendAck(PP_ACTION_DRIVE_PWM);
			}
			else if(action == PP_ACTION_GET_ODOMETRY)
			{
				Pose odometry;
				purpins.getOdometry(&odometry);
				communication.sendMsg(PP_ACTION_GET_ODOMETRY, (void*)(&odometry), sizeof(odometry));
			}
			else if(action == PP_ACTION_GET_MOTOR_SPEEDS)
			{
				MotorSpeeds speed;
				purpins.getMotorSpeeds(&speed);
				communication.sendMsg(PP_ACTION_GET_MOTOR_SPEEDS, (void*)(&speed), sizeof(speed));
			}
			else if(action == PP_ACTION_GET_ENCODER_PULSES)
			{
				EncoderPulses encoder_pulses;
				purpins.getEncoderTicks(&encoder_pulses);
				communication.sendMsg(PP_ACTION_GET_ENCODER_PULSES, (void*)(&encoder_pulses), sizeof(encoder_pulses));
			}
			else if(action == PP_ACTION_GET_IMU)
			{
				IMU imu_data;
				imu_data.orientation_x = mpu.fusedQuat[0];
				imu_data.orientation_y = mpu.fusedQuat[1];
				imu_data.orientation_z = mpu.fusedQuat[2];
				imu_data.orientation_w = mpu.fusedQuat[4];
				imu_data.linear_acceleration_x = mpu.calibratedAccel[0];
				imu_data.linear_acceleration_y = mpu.calibratedAccel[1];
				imu_data.linear_acceleration_z = mpu.calibratedAccel[2];
				imu_data.angular_velocity_x = mpu.calibratedMag[0];
				imu_data.angular_velocity_y = mpu.calibratedMag[1];
				imu_data.angular_velocity_z = mpu.calibratedMag[2];
				communication.sendMsg(PP_ACTION_GET_IMU, (void*)(&imu_data), sizeof(imu_data));
			}
			else if(action == PP_ACTION_GET_IR_SENSORS)
			{
				// TODO: Add the IR sensors
			}
			else if(action == PP_ACTION_GET_GAS_SENSOR)
			{
				// TODO: Add the gas sensor
			}
			else if(action == PP_ACTION_SET_SENSORS_PACK)
			{
				bool ok = true;
				memset(sensors_pack, 0, SENSORS_PACK_SIZE);
				if(data_size > SENSORS_PACK_SIZE)
				{
					communication.error(PP_ERROR_BUFFER_SIZE);
					ok = false;
					break;
				}
				for(unsigned int i=0 ; i<data_size ; i++)
				{
					if(data[i] < PP_ACTION_GET_ODOMETRY || data[i] > PP_ACTION_GET_GAS_SENSOR)
					{
						communication.error(PP_ERROR_SENSOR_UNKNOWN);
						ok = false;
						break;
					}
				}
				if(ok)
				{
					memcpy(sensors_pack, data, data_size);
					communication.sendAck(PP_ACTION_SET_SENSORS_PACK);
				}
			}
			else if(action == PP_ACTION_GET_SENSORS_PACK)
			{
				send_pack = true;
			}
			else if(action == PP_ACTION_SET_SENSOR_STREAMING)
			{
				float sensor_streaming_frequency;
				memcpy(&sensor_streaming_frequency, data, sizeof(sensor_streaming_frequency));
				sensor_streaming_millis = 1/sensor_streaming_frequency * 1000;
				communication.sendAck(PP_ACTION_SET_SENSOR_STREAMING);
			}
			else if(action == PP_ACTION_SET_GLOBAL_POSE)
			{
				Pose pose;
				memcpy(&pose, data, sizeof(pose));
				purpins.setGlobalPose(&pose);
				communication.sendAck(PP_ACTION_SET_GLOBAL_POSE);
			}
			else if(action == PP_ACTION_SET_NEIGHBORS_POSES)
			{
				// TODO: Finish this
			}
			else if(action == PP_ACTION_SET_ID)
			{
				memcpy(&id, data, sizeof(id));
				settings.save(PP_SETTING_ID, data, sizeof(uint32_t));
				communication.sendAck(PP_ACTION_SET_ID);
			}
			else if(action == PP_ACTION_GET_ID)
			{
				communication.sendMsg(PP_ACTION_GET_ID, (void*)(&id), sizeof(id));
			}
			else if(action == PP_ACTION_SET_PID_GAINS)
			{
				memcpy(purpins.leftPIDGains(), data, sizeof(PIDGains));
				memcpy(purpins.rightPIDGains(), data+sizeof(PIDGains), sizeof(PIDGains));
				settings.save(PP_SETTING_LEFT_PID, data, sizeof(PIDGains));
				settings.save(PP_SETTING_RIGHT_PID, data+sizeof(PIDGains), sizeof(PIDGains));
				communication.sendAck(PP_ACTION_SET_PID_GAINS);
			}
			else if(action == PP_ACTION_GET_PID_GAINS)
			{
				memcpy(data, purpins.leftPIDGains(), sizeof(PIDGains));
				memcpy(data+sizeof(PIDGains), purpins.rightPIDGains(), sizeof(PIDGains));
				communication.sendMsg(PP_ACTION_GET_ID, (void*)(data), 2*sizeof(PIDGains));
			}
			else if(action == PP_ACTION_SET_SERVER_DATA)
			{
				settings.save(PP_SETTING_SERVER_DATA, data, sizeof(Server));
				communication.sendAck(PP_ACTION_SET_SERVER_DATA);
			}
			else if(action == PP_ACTION_GET_SERVER_DATA)
			{
				settings.get(PP_SETTING_SERVER_DATA, data, sizeof(Server));
				communication.sendMsg(PP_ACTION_GET_SERVER_DATA, (void*)(data), sizeof(Server));
			}
			else if(action == PP_ACTION_SET_NETWORK_DATA)
			{
				settings.save(PP_SETTING_NETWORK_DATA, data, sizeof(Network));
				communication.sendAck(PP_ACTION_SET_NETWORK_DATA);
			}
			else if(action == PP_ACTION_GET_NETWORK_DATA)
			{
				settings.get(PP_SETTING_NETWORK_DATA, data, sizeof(Network));
				communication.sendMsg(PP_ACTION_GET_NETWORK_DATA, (void*)(data), sizeof(Network));
			}
			else if(action == PP_ACTION_SET_COMM_TYPE)
			{
				memcpy(&comm_type, data, sizeof(comm_type));
				if(comm_type != communication.type())
				{
					if(comm_type == PP_COMM_TYPE_USB)
					{
						communication.setCommLayer(uart_comm);
						if(comm != NULL) delete comm;
					}
					if(comm_type == PP_COMM_TYPE_CC3000)
					{
						if(comm != NULL) delete comm;
						comm = new WiFiComm();
						// Load network and server settings
						settings.get(PP_SETTING_NETWORK_DATA, (static_cast<WiFiComm*>(comm))->network(), sizeof(Network));
						settings.get(PP_SETTING_SERVER_DATA, (static_cast<WiFiComm*>(comm))->server(), sizeof(Server));
						// Set WiFiComm as the underlying communication layer
						communication.setCommLayer(comm);
					}
					else if(comm_type == PP_COMM_TYPE_ESP8266)
					{
						// TODO
					}
					else if(comm_type == PP_COMM_TYPE_XBEE)
					{
						// TODO
					}
					else
					{
						communication.error(PP_ERROR_COMM_UNKNOWN);
					}
					communication.sendAck(PP_ACTION_SET_COMM_TYPE);
				}
			}

		} // if(action > 0)

		//
		// Manage sensor streaming
		//
		unsigned long current_millis = millis();
		if(send_pack || (sensor_streaming_millis > 0 && (current_millis - last_millis) >= sensor_streaming_millis))
		{
			size_t size = 0;
			for(int i=0 ; i<SENSORS_PACK_SIZE ; i++)
			{
				if(sensors_pack[i] == 0) break;

				if(sensors_pack[i] == PP_ACTION_GET_ODOMETRY)
				{
					Pose odometry;
					purpins.getOdometry(&odometry);
					memcpy(data+size, &odometry, sizeof(odometry));
					size += sizeof(odometry);
				}
				else if(sensors_pack[i] == PP_ACTION_GET_MOTOR_SPEEDS)
				{
					MotorSpeeds speed;
					purpins.getMotorSpeeds(&speed);
					memcpy(data+size, &speed, sizeof(speed));
					size += sizeof(speed);
				}
				else if(sensors_pack[i] == PP_ACTION_GET_ENCODER_PULSES)
				{
					EncoderPulses encoder_pulses;
					purpins.getEncoderTicks(&encoder_pulses);
					memcpy(data+size, &encoder_pulses, sizeof(encoder_pulses));
					size += sizeof(encoder_pulses);
				}
				else if(sensors_pack[i] == PP_ACTION_GET_IMU)
				{
					IMU imu_data;
					imu_data.orientation_x = mpu.fusedQuat[0];
					imu_data.orientation_y = mpu.fusedQuat[1];
					imu_data.orientation_z = mpu.fusedQuat[2];
					imu_data.orientation_w = mpu.fusedQuat[4];
					imu_data.linear_acceleration_x = mpu.calibratedAccel[0];
					imu_data.linear_acceleration_y = mpu.calibratedAccel[1];
					imu_data.linear_acceleration_z = mpu.calibratedAccel[2];
					imu_data.angular_velocity_x = mpu.calibratedMag[0];
					imu_data.angular_velocity_y = mpu.calibratedMag[1];
					imu_data.angular_velocity_z = mpu.calibratedMag[2];
					memcpy(data+size, &imu_data, sizeof(imu_data));
					size += sizeof(imu_data);
				}
				else if(sensors_pack[i] == PP_ACTION_GET_IR_SENSORS)
				{
					// TODO: Add the IR sensors
				}
				else if(sensors_pack[i] == PP_ACTION_GET_GAS_SENSOR)
				{
					// TODO: Add the gas sensor
				}
			}

			communication.sendMsg(PP_ACTION_GET_SENSORS_PACK, (void*)(data), size);
			last_millis = current_millis;
			send_pack = false;

		} // if(send_pack ...

	} // while(1)

	return 0;
}
/*
 *  ======== EK_TM4C123GXL_initGPIO ========
 */
void EK_TM4C123GXL_initGPIO(void)
{
//    /* Setup the LED GPIO pins used */
//    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1); /* EK_TM4C123GXL_LED_RED */
//    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); /* EK_TM4C123GXL_LED_GREEN */
//    GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3); /* EK_TM4C123GXL_LED_BLUE */
//
//    /* Setup the button GPIO pins used */
//    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);  /* EK_TM4C123GXL_GPIO_SW1 */
//    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_4, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
//
//    /* PF0 requires unlocking before configuration */
//    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
//    HWREG(GPIO_PORTF_BASE + GPIO_O_CR) |= GPIO_PIN_0;
//    GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);  /* EK_TM4C123GXL_GPIO_SW2 */
//    GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_0, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPU);
//    HWREG(GPIO_PORTF_BASE + GPIO_O_LOCK) = GPIO_LOCK_M;

  //Init debug gpio pin/pins
  //
  MAP_GPIOPinTypeGPIOOutput(DEBUG_GPIO_PORT_1, DEBUG_GPIO_PIN_1);  //debug pin

  //Init radio power enable pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_GPIO_EN_PORT, INEEDMD_RADIO_ENABLE_PIN);  //radio power enable pin

  //Init radio command mode pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_GPIO_CMND_PORT, INEEDMD_RADIO_CMND_PIN);  //radio command mode pin

  //Init radio reset pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_GPIO_RST_PORT, INEEDMD_RADIO_RESET_PIN);  //radio reset pin

  //Init external clock enable pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_XTAL_PORT, INEEDMD_XTAL_ENABLE_PIN);  //external clock enable pin

  //Init ADC power on pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_ADC_GPIO_PORT, INEEDMD_ADC_PWR_PIN);

  //Init ADC reset pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_ADC_GPIO_PORT, INEEDMD_ADC_RESET_PIN);

  // Init ADC interrupt pin
  //
  MAP_GPIOPinTypeGPIOInput(INEEDMD_ADC_GPIO_PORT, INEEDMD_ADC_INTERUPT_PIN);

  // Init ADC start pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_ADC_GPIO_PORT, INEEDMD_ADC_START_PIN);

  //Init ADC nCS pin
  //
  MAP_GPIOPinTypeGPIOOutput(INEEDMD_ADC_GPIO_PORT, INEEDMD_ADC_nCS_PIN);

  //Init USB unplug detect pin
  //
  HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
  HWREG(GPIO_PORTB_BASE + GPIO_O_CR) |= GPIO_PIN_4;
  MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_4);
  MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_4, GPIO_STRENGTH_4MA, GPIO_PIN_TYPE_STD_WPD);
  HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_M;

  /* Once GPIO_init is called, GPIO_config cannot be changed */
  GPIO_init();

}
Exemple #10
0
//*****************************************************************************
//
//! Prepare a pin for use with a TOF sensor.
//!
//! \param GPIOPin is on the pin for the TOF sensor.
//!
//! This function initializes the GPIO interrupts and peripherals necessary
//! to run the corresponding GPIO port.
//!
//! The \e GPIOPin parameter can take on the following values:
//!
//! - \b PA0 - Pin PA0
//! - \b PA1 - Pin PA1
//! - \b PA2 - Pin PA2
//! - \b PA3 - Pin PA3
//! - \b PA4 - Pin PA4
//! - \b PA5 - Pin PA5
//! - \b PA6 - Pin PA6
//! - \b PA7 - Pin PA7
//! - \b PB0 - Pin PB0
//! - \b PB1 - Pin PB1
//! - \b PB2 - Pin PB2
//! - \b PB3 - Pin PB3
//! - \b PB4 - Pin PB4
//! - \b PB5 - Pin PB5
//! - \b PB6 - Pin PB6
//! - \b PB7 - Pin PB7
//! - \b PC0 - Pin PC0
//! - \b PC1 - Pin PC1
//! - \b PC2 - Pin PC2
//! - \b PC3 - Pin PC3
//! - \b PC4 - Pin PC4
//! - \b PC5 - Pin PC5
//! - \b PC6 - Pin PC6
//! - \b PC7 - Pin PC7
//! - \b PD0 - Pin PD0
//! - \b PD1 - Pin PD1
//! - \b PD2 - Pin PD2
//! - \b PD3 - Pin PD3
//! - \b PD4 - Pin PD4
//! - \b PD5 - Pin PD5
//! - \b PD6 - Pin PD6
//! - \b PD7 - Pin PD7
//! - \b PE0 - Pin PE0
//! - \b PE1 - Pin PE1
//! - \b PE2 - Pin PE2
//! - \b PE3 - Pin PE3
//! - \b PE4 - Pin PE4
//! - \b PE5 - Pin PE5
//! - \b PE6 - Pin PE6
//! - \b PE7 - Pin PE7
//! - \b PF0 - Pin PF0
//! - \b PF1 - Pin PF1
//! - \b PF2 - Pin PF2
//! - \b PF3 - Pin PF3
//! - \b PF4 - Pin PF4
//! - \b PF5 - Pin PF5
//! - \b PF6 - Pin PF6
//! - \b PF7 - Pin PF7
//!
//! \return None.
//!
//*****************************************************************************
void
TOFEchoInit(uint8_t GPIOPin)
{
    //
    // Enable Peripheral Clocks
    //
#ifdef USEPORTA
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlDelay(3);
#endif
#ifdef USEPORTB
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    MAP_SysCtlDelay(3);
#endif
#ifdef USEPORTC
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOC);
    MAP_SysCtlDelay(3);
#endif
#ifdef USEPORTD
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    MAP_SysCtlDelay(3);
#endif
#ifdef USEPORTE
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    MAP_SysCtlDelay(3);
#endif
#ifdef USEPORTF
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
    MAP_SysCtlDelay(3);
#endif

    switch(GPIOPin){
#ifdef USEPORTA
	//Puerto A
#ifdef USEPORTAPIN0
    case PA0:{
    	if(!ConfigGPIO.GPIOS.PoA0){
		//
		// Enable pin PA0 for GPIOInput
		//
    	ConfigGPIO.GPIOS.PoA0 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_0);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_0,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_0;
    	}
		break;
    }
#endif
#ifdef USEPORTAPIN1
    case PA1:{
    	if(!ConfigGPIO.GPIOS.PoA1){
		//
		// Enable pin PA1 for GPIOInput
		//
    	ConfigGPIO.GPIOS.PoA1 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_1);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_1,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_1;
    	}
		break;
    }
#endif
#ifdef USEPORTAPIN2
    case PA2:{
    	if(!ConfigGPIO.GPIOS.PoA2){
    	//
		// Enable pin PA2 for GPIOInput
		//
    	ConfigGPIO.GPIOS.PoA2 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_2,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_2;
    	}
		break;
    }
#endif
#ifdef USEPORTAPIN3
    case PA3:{
    	if(!ConfigGPIO.GPIOS.PoA3){
    	//
		// Enable pin PA3 for GPIOInput
		//
        ConfigGPIO.GPIOS.PoA3 = 1;
		GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_3);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_3,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_3;
    	}
		break;
	}
#endif
#ifdef USEPORTAPIN4
	case PA4:{
		if(!ConfigGPIO.GPIOS.PoA4){
		//
		// Enable pin PA4 for GPIOInput
		//
	    ConfigGPIO.GPIOS.PoA4 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_4);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_4,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_4;
		}
		break;
	}
#endif
#ifdef USEPORTAPIN5
	case PA5:{
		if(!ConfigGPIO.GPIOS.PoA5){
		//
		// Enable pin PA5 for GPIOInput
		//
	    ConfigGPIO.GPIOS.PoA5 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_5);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_5,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_5;
		}
		break;
	}
#endif
#ifdef USEPORTAPIN6
	case PA6:{
		if(!ConfigGPIO.GPIOS.PoA6){
		//
		// Enable pin PA6 for GPIOInput
		//
	    ConfigGPIO.GPIOS.PoA6 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_6);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_6,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_6;
		}
		break;
	}
#endif
#ifdef USEPORTAPIN7
	case PA7:{
		if(!ConfigGPIO.GPIOS.PoA7){
		//
		// Enable pin PA7 for GPIOInput
		//
		ConfigGPIO.GPIOS.PoA7 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7);
		GPIOIntTypeSet(GPIO_PORTA_BASE,GPIO_PIN_7,GPIO_HIGH_LEVEL);
		Mask[0] += GPIO_INT_PIN_7;
		}
		break;
	}
#endif
#endif
#ifdef USEPORTB
	//Puerto B
#ifdef USEPORTBPIN0
	case PB0:{
		if(!ConfigGPIO.GPIOS.PoB0){
		//
		// Enable pin PB0 for GPIOInput
		//
		ConfigGPIO.GPIOS.PoB0 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_0);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_0,GPIO_HIGH_LEVEL);
		Mask[1] += GPIO_INT_PIN_0;
		}
		break;
	}
#endif
#ifdef USEPORTBPIN1
	case PB1:{
		if(!ConfigGPIO.GPIOS.PoB1){
		//
		// Enable pin PB1 for GPIOInput
		//
		ConfigGPIO.GPIOS.PoB1 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_1);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_1,GPIO_HIGH_LEVEL);
		Mask[1] += GPIO_INT_PIN_0;
		}
		break;
	}
#endif
#ifdef USEPORTBPIN2
	case PB2:{
		if(!ConfigGPIO.GPIOS.PoB2){
		//
		// Enable pin PB2 for GPIOInput
		//
		ConfigGPIO.GPIOS.PoB2 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_2,GPIO_HIGH_LEVEL);
		Mask[1] += GPIO_INT_PIN_2;
		}
		break;
	}
#endif
#ifdef USEPORTBPIN3
	case PB3:{
		if(!ConfigGPIO.GPIOS.PoB3){
		//
		// Enable pin PB3 for GPIOInput
		//
		ConfigGPIO.GPIOS.PoB3 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_3);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_3,GPIO_RISING_EDGE  );
		Mask[1] += GPIO_INT_PIN_3;
		}
		break;
	}
#endif
#ifdef USEPORTBPIN4
	case PB4:{
		if(!ConfigGPIO.GPIOS.PoB4){
		//
		// Enable pin PB4 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoB4 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_4);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_4,GPIO_HIGH_LEVEL);
		Mask[1] += GPIO_INT_PIN_4;
		}
		break;
	}
#endif
#ifdef USEPORTBPIN5
	case PB5:{
		if(!ConfigGPIO.GPIOS.PoB5){
		//
		// Enable pin PB5 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoB5 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_5,GPIO_HIGH_LEVEL);
		Mask[1] += GPIO_INT_PIN_5;
		}
		break;
	}
#endif
#ifdef USEPORTBPIN6
	case PB6:{
		if(!ConfigGPIO.GPIOS.PoB6){
		//
		// Enable pin PB6 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoB6 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_6,GPIO_HIGH_LEVEL);
		Mask[1] += GPIO_INT_PIN_6;
		}
		break;
	}
#endif
#ifdef USEPORTBPIN7
	case PB7:{
		if(!ConfigGPIO.GPIOS.PoB7){
		//
		// Enable pin PB7 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoB7 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_7);
		GPIOIntTypeSet(GPIO_PORTB_BASE,GPIO_PIN_7,GPIO_HIGH_LEVEL);
		Mask[1] += GPIO_INT_PIN_7;
		}
			break;
		}
#endif
#endif
#ifdef USEPORTC
	//Puerto C
#ifdef USEPORTCPIN4
	case PC4:{
		if(!ConfigGPIO.GPIOS.PoC4){
		//
		// Enable pin PC4 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoC4 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_4);
		GPIOIntTypeSet(GPIO_PORTC_BASE,GPIO_PIN_4,GPIO_HIGH_LEVEL);
		Mask[2] += GPIO_INT_PIN_4;
		}
		break;
	}
#endif
#ifdef USEPORTCPIN5
	case PC5:{
		if(!ConfigGPIO.GPIOS.PoC5){
		//
		// Enable pin PC5 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoC5 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_5);
		GPIOIntTypeSet(GPIO_PORTC_BASE,GPIO_PIN_5,GPIO_HIGH_LEVEL);
		Mask[2] += GPIO_INT_PIN_5;
		}
		break;
	}
#endif
#ifdef USEPORTCPIN6
	case PC6:{
		if(!ConfigGPIO.GPIOS.PoC6){
		//
		// Enable pin PC6 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoC6 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_6);
		GPIOIntTypeSet(GPIO_PORTC_BASE,GPIO_PIN_6,GPIO_HIGH_LEVEL);
		Mask[2] += GPIO_INT_PIN_6;
		}
		break;
	}
#endif
#ifdef USEPORTCPIN7
	case PC7:{
		if(!ConfigGPIO.GPIOS.PoC7){
		//
		// Enable pin PC7 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoC7 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTC_BASE, GPIO_PIN_7);
		GPIOIntTypeSet(GPIO_PORTC_BASE,GPIO_PIN_7,GPIO_HIGH_LEVEL);
		Mask[2] += GPIO_INT_PIN_7;
		}
		break;
	}
#endif
#endif
#ifdef USEPORTD
	//Puerto D
#ifdef USEPORTDPIN0
	case PD0:{
		if(!ConfigGPIO.GPIOS.PoD0){
		//
		// Enable pin PD0 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoD0 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_0);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_0,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_0;
		}
		break;
	}
#endif
#ifdef USEPORTDPIN1
	case PD1:{
		if(!ConfigGPIO.GPIOS.PoD1){
		//
		// Enable pin PD1 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoD1 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_1);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_1,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_1;
		}
		break;
	}
#endif
#ifdef USEPORTDPIN2
	case PD2:{
		if(!ConfigGPIO.GPIOS.PoD2){
		//
		// Enable pin PD2 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoD2 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_2);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_2,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_2;
		}
		break;
	}
#endif
#ifdef USEPORTDPIN3
	case PD3:{
		if(!ConfigGPIO.GPIOS.PoD3){
		//
		// Enable pin PD3 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoD3 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_3);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_3,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_3;
		}
		break;
	}
#endif
#ifdef USEPORTDPIN4
	case PD4:{
		if(!ConfigGPIO.GPIOS.PoD4){
		//
		// Enable pin PD4 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoD4 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_4);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_4,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_4;
		}
		break;
	}
#endif
#ifdef USEPORTDPIN5
	case PD5:{
		if(!ConfigGPIO.GPIOS.PoD5){
		//
		// Enable pin PD5 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoD5 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_5);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_5,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_5;
		}
		break;
	}
#endif
#ifdef USEPORTDPIN6
	case PD6:{
		if(!ConfigGPIO.GPIOS.PoD6){
		//
		// Enable pin PD6 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoD6 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_6);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_6,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_6;
		}
		break;
	}
#endif
#ifdef USEPORTDPIN7
	case PD7:{
		if(!ConfigGPIO.GPIOS.PoD7){
		//
		// Enable pin PD7 for GPIOInput
		//

		//
		//First open the lock and select the bits we want to modify in the GPIO commit register.
		//
		HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY;
		HWREG(GPIO_PORTD_BASE + GPIO_O_CR) = 0x80;

		//
		//Now modify the configuration of the pins that we unlocked.
		//
		ConfigGPIO.GPIOS.PoD7 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTD_BASE, GPIO_PIN_7);
		GPIOIntTypeSet(GPIO_PORTD_BASE,GPIO_PIN_7,GPIO_HIGH_LEVEL);
		Mask[3] += GPIO_INT_PIN_7;
		}
		break;
	}
#endif
#endif
#ifdef USEPORTE
	//Puerto E
#ifdef USEPORTEPIN0
	case PE0:{
		if(!ConfigGPIO.GPIOS.PoE0){
		//
		// Enable pin PE0 for GPIOInput
		//
		ConfigGPIO.GPIOS.PoE0 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0);
		GPIOIntTypeSet(GPIO_PORTE_BASE,GPIO_PIN_0,GPIO_HIGH_LEVEL);
		Mask[4] += GPIO_INT_PIN_0;
		}
		break;
	}
#endif
#ifdef USEPORTEPIN1
	case PE1:{
		if(!ConfigGPIO.GPIOS.PoE1){
		//
		// Enable pin PE1 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoE1 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1);
		GPIOIntTypeSet(GPIO_PORTE_BASE,GPIO_PIN_1,GPIO_HIGH_LEVEL);
		Mask[4] += GPIO_INT_PIN_1;
		}
		break;
	}
#endif
#ifdef USEPORTEPIN2
	case PE2:{
		if(!ConfigGPIO.GPIOS.PoE2){
		//
		// Enable pin PE2 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoE2 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_2);
		GPIOIntTypeSet(GPIO_PORTE_BASE,GPIO_PIN_2,GPIO_HIGH_LEVEL);
		Mask[4] += GPIO_INT_PIN_2;
		}

		//	break;
	}
#endif
#ifdef USEPORTEPIN3
	case PE3:{
		if(!ConfigGPIO.GPIOS.PoE3){
		// Enable pin PE3 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoE3 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_3);
		GPIOIntTypeSet(GPIO_PORTE_BASE,GPIO_PIN_3,GPIO_HIGH_LEVEL);
		Mask[4] += GPIO_INT_PIN_3;
		}
		break;
	}
#endif
#ifdef USEPORTEPIN4
	case PE4:{
		if(!ConfigGPIO.GPIOS.PoE4){
		//
		// Enable pin PE4 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoE4 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_4);
		GPIOIntTypeSet(GPIO_PORTE_BASE,GPIO_PIN_4,GPIO_HIGH_LEVEL);
		Mask[4] += GPIO_INT_PIN_4;
		}
		break;
	}
#endif
#ifdef USEPORTEPIN5
	case PE5:{
		if(!ConfigGPIO.GPIOS.PoE5){
		//
		// Enable pin PE5 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoE5 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_5);
		GPIOIntTypeSet(GPIO_PORTE_BASE,GPIO_PIN_5,GPIO_HIGH_LEVEL);
		Mask[4] += GPIO_INT_PIN_5;
		}
		break;
	}
#endif
#endif
#ifdef USEPORTF
	//Puerto F
#ifdef USEPORTFPIN0
	case PF0:{
		if(!ConfigGPIO.GPIOS.PoF0){
		//
		// Enable pin PF0 for GPIOInput
		//

		//
		//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.
		//
		ConfigGPIO.GPIOS.PoF0 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);
		GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_0,GPIO_HIGH_LEVEL);
		Mask[5] += GPIO_INT_PIN_0;
		}
		break;
	}
#endif
#ifdef USEPORTFPIN1
	case PF1:{
		if(!ConfigGPIO.GPIOS.PoF1){
		//
		// Enable pin PF1 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoF1 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1);
		GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_1,GPIO_HIGH_LEVEL);
		Mask[5] += GPIO_INT_PIN_1;
		}
		break;
	}
#endif
#ifdef USEPORTFPIN2
	case PF2:{
		if(!ConfigGPIO.GPIOS.PoF2){
		//
		// Enable pin PF2 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoF2 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_2);
		GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_2,GPIO_HIGH_LEVEL);
		Mask[5] += GPIO_INT_PIN_2;
		}
		break;
	}
#endif
#ifdef USEPORTFPIN3
	case PF3:{
		if(!ConfigGPIO.GPIOS.PoF3){
		//
		// Enable pin PF3 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoF3 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_3);
		GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_3,GPIO_HIGH_LEVEL);
		Mask[5] += GPIO_INT_PIN_3;
		}
		break;
	}
#endif
#ifdef USEPORTFPIN4
	case PF4:{
		if(!ConfigGPIO.GPIOS.PoF4){
		//
		// Enable pin PF4 for GPIOInput
		//
			ConfigGPIO.GPIOS.PoF4 = 1;
		MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);
		GPIOIntTypeSet(GPIO_PORTF_BASE,GPIO_PIN_4,GPIO_HIGH_LEVEL);
		Mask[5] += GPIO_INT_PIN_4;
		}
		break;
	}
#endif
#endif
	default: break;

    }
	GPIOIntClear(GPIO_PORTA_BASE,0x0F);
	GPIOIntClear(GPIO_PORTB_BASE,0x0F);
	GPIOIntClear(GPIO_PORTC_BASE,0x0F);
	GPIOIntClear(GPIO_PORTD_BASE,0x0F);
	GPIOIntClear(GPIO_PORTE_BASE,0x0F);
	GPIOIntClear(GPIO_PORTF_BASE,0x0F);
	GPIOIntDisable(GPIO_PORTA_BASE,0x0F);
	GPIOIntDisable(GPIO_PORTB_BASE,0x0F);
	GPIOIntDisable(GPIO_PORTC_BASE,0x0F);
	GPIOIntDisable(GPIO_PORTD_BASE,0x0F);
	GPIOIntDisable(GPIO_PORTE_BASE,0x0F);
	GPIOIntDisable(GPIO_PORTF_BASE,0x0F);

#ifdef USEPORTA
	//Habilitacion de las interrupciones:
	//Puerto A con algo configurado
	if(ConfigGPIO.PortGpio[0] >0){

		//Primero deshabilita configura habilita
		 //IntEnable(INT_GPIOA);
		GPIOIntEnable(GPIO_PORTA_BASE,Mask[0]);
		//GPIOPadConfigSet(GPIO_PORTA_BASE,Mask[0],GPIO_STRENGTH_2MA,GPIO_PIN_TYPE_STD_WPD);
		GPIOIntRegister(GPIO_PORTA_BASE,TOFProcess);
		//GPIOIntTypeSet(GPIO_PORTA_BASE,Mask[0],GPIO_RISING_EDGE);


	}
#endif

#ifdef USEPORTB
	//Puerto B con algo configurado
	if(ConfigGPIO.PortGpio[1] >0){
	//	GPIOIntTypeSet(GPIO_PORTB_BASE,Mask[1],GPIO_PIN_TYPE_STD_WPD);
		GPIOIntRegister(GPIO_PORTB_BASE,TOFProcess);
		GPIOIntEnable(GPIO_PORTB_BASE,Mask[1]);

	}
#endif
#ifdef USEPORTC
	//Puerto C con algo configurado
	if(ConfigGPIO.PortGpio[2] >0){
		GPIOIntEnable(GPIO_PORTC_BASE,Mask[2]);
		GPIOIntRegister(GPIO_PORTC_BASE,TOFProcess);
	}
#endif
#ifdef USEPORTD
	//Puerto D con algo configurado
	if(ConfigGPIO.PortGpio[3] >0){
		GPIOIntEnable(GPIO_PORTD_BASE,Mask[3]);
		GPIOIntRegister(GPIO_PORTD_BASE,TOFProcess);
	}
#endif
#ifdef USEPORTE
	//Puerto E con algo configurado
	if(ConfigGPIO.PortGpio[4] >0){
		GPIOIntEnable(GPIO_PORTE_BASE,Mask[4]);
		GPIOIntRegister(GPIO_PORTE_BASE,TOFProcess);
	}
#endif
#ifdef USEPORTF
	//Puerto F con algo configurado
	if(ConfigGPIO.PortGpio[5] >0){
		GPIOIntEnable(GPIO_PORTF_BASE,Mask[5]);
		GPIOIntRegister(GPIO_PORTF_BASE,TOFProcess);
	}
#endif
//	IntMasterEnable();



}
Exemple #11
0
//*****************************************************************************
//
//! Configures the device pins for the customer specific usage.
//!
//! \return None.
//
//*****************************************************************************
void
PinoutSet(void)
{
    //
    // Enable Peripheral Clocks 
    //
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Configure the GPIO Pin Mux for PB6
	// for GPIO_PB6
    //
	MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6);

    //
    // Configure the GPIO Pin Mux for PB7
	// for GPIO_PB7
    //
	MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_7);

    //
    // Configure the GPIO Pin Mux for PB0
	// for GPIO_PB0
    //
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0);

    //
    // Configure the GPIO Pin Mux for PB1
	// for GPIO_PB1
    //
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_1);

    //
    // Configure the GPIO Pin Mux for PB2
	// for GPIO_PB2
    //
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_2);

    //
    // Configure the GPIO Pin Mux for PB3
	// for GPIO_PB3
    //
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_3);

    //
    // Configure the GPIO Pin Mux for PB4
	// for GPIO_PB4
    //
	MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_4);

    //
    // Configure the GPIO Pin Mux for PB5
	// for GPIO_PB5
    //
	MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_5);

    //
    // Configure the GPIO Pin Mux for PF4
	// for GPIO_PF4
    //
	MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);

	//
	// Unlock the Port Pin and Set the Commit Bit
	//
	HWREG(GPIO_PORTF_BASE+GPIO_O_LOCK) = GPIO_LOCK_KEY;
	HWREG(GPIO_PORTF_BASE+GPIO_O_CR)   |= GPIO_PIN_0;
	HWREG(GPIO_PORTF_BASE+GPIO_O_LOCK) = 0x0;

    //
    // Configure the GPIO Pin Mux for PF0
	// for GPIO_PF0
    //
	MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);

    //
    // Configure the GPIO Pin Mux for PD2
	// for SSI3RX
    //
	MAP_GPIOPinConfigure(GPIO_PD2_SSI3RX);
	MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_2);

    //
    // Configure the GPIO Pin Mux for PD1
	// for SSI3FSS
    //
	MAP_GPIOPinConfigure(GPIO_PD1_SSI3FSS);
	MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_1);

    //
    // Configure the GPIO Pin Mux for PD3
	// for SSI3TX
    //
	MAP_GPIOPinConfigure(GPIO_PD3_SSI3TX);
	MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3);

    //
    // Configure the GPIO Pin Mux for PD0
	// for SSI3CLK
    //
	MAP_GPIOPinConfigure(GPIO_PD0_SSI3CLK);
	MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0);

    //
    // Configure the GPIO Pin Mux for PA4
	// for SSI0RX
    //
	MAP_GPIOPinConfigure(GPIO_PA4_SSI0RX);
	MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_4);

    //
    // Configure the GPIO Pin Mux for PA3
	// for SSI0FSS
    //
	MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
	MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_3);

    //
    // Configure the GPIO Pin Mux for PA5
	// for SSI0TX
    //
	MAP_GPIOPinConfigure(GPIO_PA5_SSI0TX);
	MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5);

    //
    // Configure the GPIO Pin Mux for PA2
	// for SSI0CLK
    //
	MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
	MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2);

}
Exemple #12
0
//*****************************************************************************
void
PortFunctionInit(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI3);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable pin PA2 for GPIOInput
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_2);

    //
    // Enable pin PF3 for SSI1 SSI1FSS
    //
    MAP_GPIOPinConfigure(GPIO_PF3_SSI1FSS);
    MAP_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_3);

    //
    // Enable pin PF0 for SSI1 SSI1RX
    // 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.
    //
    MAP_GPIOPinConfigure(GPIO_PF0_SSI1RX);
    MAP_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_0);

    //
    // Enable pin PF1 for SSI1 SSI1TX
    //
    MAP_GPIOPinConfigure(GPIO_PF1_SSI1TX);
    MAP_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_1);

    //
    // Enable pin PF2 for SSI1 SSI1CLK
    //
    MAP_GPIOPinConfigure(GPIO_PF2_SSI1CLK);
    MAP_GPIOPinTypeSSI(GPIO_PORTF_BASE, GPIO_PIN_2);

    //
    // Enable pin PD3 for SSI3 SSI3TX
    //
    MAP_GPIOPinConfigure(GPIO_PD3_SSI3TX);
    MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_3);

    //
    // Enable pin PD2 for SSI3 SSI3RX
    //
    MAP_GPIOPinConfigure(GPIO_PD2_SSI3RX);
    MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_2);

    //
    // Enable pin PD0 for SSI3 SSI3CLK
    //
    MAP_GPIOPinConfigure(GPIO_PD0_SSI3CLK);
    MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_0);

    //
    // Enable pin PD1 for SSI3 SSI3FSS
    //
    MAP_GPIOPinConfigure(GPIO_PD1_SSI3FSS);
    MAP_GPIOPinTypeSSI(GPIO_PORTD_BASE, GPIO_PIN_1);
}
Exemple #13
0
//*****************************************************************************
void
PortFunctionInit(void)
{
    //
    // Enable Peripheral Clocks
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_USB0);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable pin PA7 for GPIOInput
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7);

    //
    // Enable pin PA6 for GPIOInput - SPI Current Word is Header Word
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_6);

    //
    // Enable pin PF2 for GPIOInput
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_2);

    //
    // Enable pin PF3 for GPIOInput
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_3);

    //
    // Enable pin PF1 for GPIOOutputOD
    //
    MAP_GPIOPinTypeGPIOOutputOD(GPIO_PORTF_BASE, GPIO_PIN_1);

    //
    // Enable pin PA5 for SSI0 SSI0TX
    //
    MAP_GPIOPinConfigure(GPIO_PA5_SSI0TX);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5);

    //
    // Enable pin PA4 for SSI0 SSI0RX
    //
    MAP_GPIOPinConfigure(GPIO_PA4_SSI0RX);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_4);

    //
    // Enable pin PA2 for SSI0 SSI0CLK
    //
    MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2);

    //
    // Enable pin PA3 for SSI0 SSI0FSS
    //
    MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_3);

    //
    // Enable pin PA0 for UART0 U0RX
    //
    MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
    MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0);

    //
    // Enable pin PA1 for UART0 U0TX
    //
    MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
    MAP_GPIOPinTypeUART(GPIO_PORTA_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);
}
Exemple #14
0
//*****************************************************************************
void
PortFunctionInit(void)
{
    //
    // Enable Peripheral Clocks 
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN0);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);

    //
    // Enable port PE5 for CAN0 CAN0TX
    //
    MAP_GPIOPinConfigure(GPIO_PE5_CAN0TX);
    MAP_GPIOPinTypeCAN(GPIO_PORTE_BASE, GPIO_PIN_5);

    //
    // Enable port PE4 for CAN0 CAN0RX
    //
    MAP_GPIOPinConfigure(GPIO_PE4_CAN0RX);
    MAP_GPIOPinTypeCAN(GPIO_PORTE_BASE, GPIO_PIN_4);

    //
    // Enable port PB0 for GPIOOutput
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_0);

    //
    // Enable port PB6 for GPIOInput
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_6);

    //
    // Enable port PF4 for GPIOInput
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_4);

    //
    // Enable port PF0 for GPIOInput
    //

    //
    //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_DD;
    HWREG(GPIO_PORTF_BASE + GPIO_O_CR) = 0x1;

    //
    //Now modify the configuration of the pins that we unlocked.
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_0);

    //
    // Enable port PF3 for GPIOOutput
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_3);

    //
    // Enable port PF2 for GPIOOutput
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2);

    //
    // Enable port PF1 for GPIOOutput
    //
    MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);

    //
    // Enable port PA3 for SSI0 SSI0FSS
    //
    MAP_GPIOPinConfigure(GPIO_PA3_SSI0FSS);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_3);

    //
    // Enable port PA2 for SSI0 SSI0CLK
    //
    MAP_GPIOPinConfigure(GPIO_PA2_SSI0CLK);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2);

    //
    // Enable port PA4 for SSI0 SSI0RX
    //
    MAP_GPIOPinConfigure(GPIO_PA4_SSI0RX);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_4);

    //
    // Enable port PA5 for SSI0 SSI0TX
    //
    MAP_GPIOPinConfigure(GPIO_PA5_SSI0TX);
    MAP_GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_5);
}
Exemple #15
0
//*****************************************************************************
//
// Initialize the I2C, MPU9150 and Gesture systems.
//
//*****************************************************************************
void
MotionInit(void)
{
    //
    // Enable port S used for motion interrupt.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOS);

    //
    // The I2C3 peripheral must be enabled before use.
    //
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);

    //
    // Configure the pin muxing for I2C3 functions on port G4 and G5.
    //
    MAP_GPIOPinConfigure(GPIO_PG4_I2C3SCL);
    MAP_GPIOPinConfigure(GPIO_PG5_I2C3SDA);

    //
    // Select the I2C function for these pins.  This function will also
    // configure the GPIO pins pins for I2C operation, setting them to
    // open-drain operation with weak pull-ups.  Consult the data sheet
    // to see which functions are allocated per pin.
    //
    MAP_GPIOPinTypeI2CSCL(GPIO_PORTG_BASE, GPIO_PIN_4);
    MAP_GPIOPinTypeI2C(GPIO_PORTG_BASE, GPIO_PIN_5);

    //
    // Configure and Enable the GPIO interrupt. Used for INT signal from the
    // MPU9150
    //
    MAP_GPIOPinTypeGPIOInput(GPIO_PORTS_BASE, GPIO_PIN_2);
    MAP_GPIOIntEnable(GPIO_PORTS_BASE, GPIO_PIN_2);
    MAP_GPIOIntTypeSet(GPIO_PORTS_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE);
    MAP_IntEnable(INT_GPIOS);

    //
    // Enable interrupts to the processor.
    //
    MAP_IntMasterEnable();

    //
    // Initialize I2C3 peripheral.
    //
    I2CMInit(&g_sI2CInst, I2C3_BASE, INT_I2C3, 0xff, 0xff,
             g_ui32SysClock);

    //
    // Set the motion state to initializing.
    //
    g_ui8MotionState = MOTION_STATE_INIT;

    //
    // Initialize the MPU9150 Driver.
    //
    MPU9150Init(&g_sMPU9150Inst, &g_sI2CInst, MPU9150_I2C_ADDRESS,
                MotionCallback, &g_sMPU9150Inst);

    //
    // Wait for transaction to complete
    //
    MotionI2CWait(__FILE__, __LINE__);

    //
    // Write application specifice sensor configuration such as filter settings
    // and sensor range settings.
    //
    g_sMPU9150Inst.pui8Data[0] = MPU9150_CONFIG_DLPF_CFG_94_98;
    g_sMPU9150Inst.pui8Data[1] = MPU9150_GYRO_CONFIG_FS_SEL_250;
    g_sMPU9150Inst.pui8Data[2] = (MPU9150_ACCEL_CONFIG_ACCEL_HPF_5HZ |
                                  MPU9150_ACCEL_CONFIG_AFS_SEL_2G);
    MPU9150Write(&g_sMPU9150Inst, MPU9150_O_CONFIG, g_sMPU9150Inst.pui8Data, 3,
                 MotionCallback, &g_sMPU9150Inst);

    //
    // Wait for transaction to complete
    //
    MotionI2CWait(__FILE__, __LINE__);

    //
    // Configure the data ready interrupt pin output of the MPU9150.
    //
    g_sMPU9150Inst.pui8Data[0] = (MPU9150_INT_PIN_CFG_INT_LEVEL |
                                  MPU9150_INT_PIN_CFG_INT_RD_CLEAR |
                                  MPU9150_INT_PIN_CFG_LATCH_INT_EN);
    g_sMPU9150Inst.pui8Data[1] = MPU9150_INT_ENABLE_DATA_RDY_EN;
    MPU9150Write(&g_sMPU9150Inst, MPU9150_O_INT_PIN_CFG,
                 g_sMPU9150Inst.pui8Data, 2, MotionCallback, &g_sMPU9150Inst);

    //
    // Wait for transaction to complete
    //
    MotionI2CWait(__FILE__, __LINE__);

    //
    // Initialize the DCM system.
    //
    CompDCMInit(&g_sCompDCMInst, 1.0f / ((float) MOTION_SAMPLE_FREQ_HZ),
                DCM_ACCEL_WEIGHT, DCM_GYRO_WEIGHT, DCM_MAG_WEIGHT);

    //
    // Initialize the gesture instance and establish a initial state estimate.
    //
    GestureInit(&g_sGestureInst, g_pfInitProb, g_ppfPath, g_ppfTransitionProb,
                g_ppfEmitProb, GESTURE_PATH_LENGTH, GESTURE_NUM_STATES,
                GESTURE_STATE_IDLE);
}
Exemple #16
0
void pio_init()
{
					 //  Board Initialization start
				 //
				 //
				 // The FPU should be enabled because some compilers will use floating-
				 // point registers, even for non-floating-point code.  If the FPU is not
				 // enabled this will cause a fault.  This also ensures that floating-
				 // point operations could be added to this application and would work
				 // correctly and use the hardware floating-point unit.  Finally, lazy
				 // stacking is enabled for interrupt handlers.  This allows floating-
				 // point instructions to be used within interrupt handlers, but at the
				 // expense of extra stack usage.
				 //
				 FPUEnable(); 
				 FPULazyStackingEnable();	  
				 
				 //Init the device with 16 MHz clock.
				 initClk();
	
                 /* Configure the system peripheral bus that IRQ & EN pin are map to */
					MAP_SysCtlPeripheralEnable( SYSCTL_PERIPH_IRQ_PORT);
					//
					// Disable all the interrupts before configuring the lines
					//
					MAP_GPIOPinIntDisable(SPI_GPIO_IRQ_BASE, 0xFF);
					//
					// Cofigure WLAN_IRQ pin as input
					//
					MAP_GPIOPinTypeGPIOInput(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN);

					GPIOPadConfigSet(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN, GPIO_STRENGTH_2MA,
												GPIO_PIN_TYPE_STD_WPU);     
					//
					// Setup the GPIO interrupt for this pin
					//
					MAP_GPIOIntTypeSet(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN, GPIO_FALLING_EDGE);

					//
					// Configure WLAN chip
					//
                    MAP_GPIOPinTypeGPIOOutput(SPI_GPIO_IRQ_BASE, SPI_EN_PIN);
                    MAP_GPIODirModeSet( SPI_GPIO_IRQ_BASE, SPI_EN_PIN, GPIO_DIR_MODE_OUT );
                    MAP_GPIOPadConfigSet( SPI_GPIO_IRQ_BASE, SPI_EN_PIN, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD );



					MAP_GPIOPinWrite(SPI_GPIO_IRQ_BASE, SPI_EN_PIN, PIN_LOW);	
					SysCtlDelay(600000);
					SysCtlDelay(600000);
					SysCtlDelay(600000);
					//
					// Disable WLAN CS with pull up Resistor
					//
					MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_SPI_PORT);	
					MAP_GPIOPinTypeGPIOOutput(SPI_CS_PORT, SPI_CS_PIN);
					GPIOPadConfigSet(SPI_CS_PORT, SPI_CS_PIN, GPIO_STRENGTH_2MA,
												GPIO_PIN_TYPE_STD_WPU);     
					MAP_GPIOPinWrite(SPI_CS_PORT, SPI_CS_PIN, PIN_HIGH);

					// 
					// Enable interrupt for WLAN_IRQ pin
					//
					MAP_GPIOPinIntEnable(SPI_GPIO_IRQ_BASE, SPI_IRQ_PIN);
					// 
					// Clear interrupt status
					//
					SpiCleanGPIOISR();

					MAP_IntEnable(INT_GPIO_SPI);
					
					//init LED
					initLEDs();

}
Exemple #17
0
/*
 * initialize tm4c
 */
void init_satellite()
{
	FPUEnable();
	FPULazyStackingEnable();

	/*
	 * init clock
	 */
	MAP_SysCtlClockSet(SYSCTL_SYSDIV_3 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);	//66.6..MHz

	MAP_IntMasterEnable();

	/*
	 * Enable peripherals
	 */
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);	//for LED indication

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);	//for UART
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);	//for IRQ and SW_EN
	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);	//for SPI


	/*
	 * configure
	 */
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3);
	MAP_GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3, SIGNAL_LOW);	//off

	MAP_GPIOPinConfigure(GPIO_PA0_U0RX);
	MAP_GPIOPinConfigure(GPIO_PA1_U0TX);
	MAP_GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
	UARTStdioConfig(UART_PORT, UART_BAUDRATE, SysCtlClockGet());


	MAP_GPIOIntDisable(GPIO_PORTB_BASE, SIGNAL_HIGH);	//interrupt disable

	MAP_GPIOPinTypeGPIOInput(GPIO_PORTB_BASE, GPIO_PIN_2);	//IRQ as input
	MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	MAP_GPIOIntTypeSet(GPIO_PORTB_BASE, GPIO_PIN_2, GPIO_FALLING_EDGE);		//enable interrupt

	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTB_BASE, GPIO_PIN_5);	//sw enable
	MAP_GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_DIR_MODE_OUT);
	MAP_GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_5, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPD);

	MAP_GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_5, SIGNAL_LOW);

	MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
	MAP_GPIOPinTypeGPIOOutput(GPIO_PORTE_BASE, GPIO_PIN_0);

	MAP_GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);
	MAP_GPIOPinWrite(GPIO_PORTE_BASE, GPIO_PIN_0, SIGNAL_HIGH);	//chip select

	MAP_GPIOIntEnable(GPIO_PORTB_BASE, GPIO_PIN_2);	//enable interrupt for WLAN_IRQ pin

	SpiCleanGPIOISR();	//clear interrupt status

	MAP_IntEnable(INT_GPIOB);	//spi


	init_worker();

	setState(READY);
}