/******************************************************************
*  Copyright (C) 2009 Ram Narula  
*  Filename: definePin.cpp
*  Version: 0.11
*  Date: 16 July 2009
*  Information: http://www.xduino.com/    
******************************************************************/
/******************************************************************
*   This file is part of Xduino
*
*   Xduino is free software: you can redistribute it and/or modify
*   it under the terms of the GNU Lesser General Public License as published by
*   the Free Software Foundation, either version 3 of the License, or
*   (at your option) any later version.
*	
*   Xduino is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU Lesser General Public License for more details.
*
*   You should have received a copy of the GNU Lesser General Public License
*   along with Xduino.  If not, see .
******************************************************************/

extern "C" {
#include "stm32f10x_lib.h"
}
#include "definePin.h"


definePin::definePin(u8 Pxn)
{

switch ((Pxn & 0xF0) >> 4)		//AND with 11110000 and right shift 4 bits
{						
	case 1:
		GPIObank=GPIOA;
		break;
	case 2:
		GPIObank=GPIOB;
		break;
	case 3:
		GPIObank=GPIOC;
		break;
	case 4:
		GPIObank=GPIOD;
		break;
	case 5:
		GPIObank=GPIOE;
		break;
	case 6:
		GPIObank=GPIOF;
		break;
	case 7:
		GPIObank=GPIOG;
		break;
}

switch (Pxn & 0x0F)				//AND with 00001111 to get the first 4 bits Pin number
{
	case 0:
		GPIOPin=GPIO_Pin_0;
		break;
	case 1:
		GPIOPin=GPIO_Pin_1;
		break;
	case 2:
		GPIOPin=GPIO_Pin_2;
		break;
	case 3:
		GPIOPin=GPIO_Pin_3;
		break;
	case 4:
		GPIOPin=GPIO_Pin_4;
		break;
	case 5:
		GPIOPin=GPIO_Pin_5;
		break;
	case 6:
		GPIOPin=GPIO_Pin_6;
		break;
	case 7:
		GPIOPin=GPIO_Pin_7;
		break;
	case 8:
		GPIOPin=GPIO_Pin_8;
		break;
	case 9:
		GPIOPin=GPIO_Pin_9;
		break;
	case 10:
		GPIOPin=GPIO_Pin_10;
		break;
	case 11:
		GPIOPin=GPIO_Pin_11;
		break;
	case 12:
		GPIOPin=GPIO_Pin_12;
		break;
	case 13:
		GPIOPin=GPIO_Pin_13;
		break;
	case 14:
		GPIOPin=GPIO_Pin_14;
		break;
	case 15:
		GPIOPin=GPIO_Pin_15;
		break;
	default:
		break;
}			

}