mirror of https://github.com/ARMmbed/mbed-os.git
commit
0c2ffe5e58
|
@ -12,16 +12,10 @@ void HAL_GPIO_DeInit(GPIO_TypeDef* GPIOx)
|
||||||
|
|
||||||
/* DeInit GPIOx Registers */
|
/* DeInit GPIOx Registers */
|
||||||
GPIOx->DATA = 0x0000;
|
GPIOx->DATA = 0x0000;
|
||||||
GPIOx->DATAOUT = 0x0000;
|
GPIOx->DATAOUT = 0x0000;
|
||||||
//GPIOx->OUTENSET = 0x0000;
|
GPIOx->OUTENCLR = 0xFFFF;
|
||||||
GPIOx->OUTENCLR = 0xFFFF;
|
|
||||||
//GPIOx->INTENSET = 0x0000;
|
|
||||||
GPIOx->INTENCLR = 0xFFFF;
|
GPIOx->INTENCLR = 0xFFFF;
|
||||||
//GPIOx->INTTYPESET = 0x0000;
|
GPIOx->INTTYPESET = 0x0000;
|
||||||
GPIOx->INTTYPECLR = 0xFFFF;
|
|
||||||
//GPIOx->INTPOLSET = 0x0000;
|
|
||||||
GPIOx->INTPOLCLR = 0xFFFF;
|
|
||||||
|
|
||||||
|
|
||||||
/* DeInit GPIOx
|
/* DeInit GPIOx
|
||||||
* Pad Control Register
|
* Pad Control Register
|
||||||
|
@ -65,9 +59,8 @@ void HAL_GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
|
||||||
|
|
||||||
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
|
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
|
||||||
assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
|
assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Pin));
|
||||||
// assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));
|
assert_param(IS_GPIO_PIN(GPIO_InitStruct->GPIO_Mode));
|
||||||
|
assert_param(IS_GPIO_PUPD(GPIO_InitStruct->GPIO_PuPd));
|
||||||
GPIOx->INTTYPESET = 0x00FF;
|
|
||||||
|
|
||||||
if (GPIOx == GPIOA) px_pcr = PA_PCR;
|
if (GPIOx == GPIOA) px_pcr = PA_PCR;
|
||||||
else if (GPIOx == GPIOB) px_pcr = PB_PCR;
|
else if (GPIOx == GPIOB) px_pcr = PB_PCR;
|
||||||
|
@ -117,16 +110,6 @@ void HAL_GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)
|
||||||
px_pcr->Port[pinpos] &= ~(Px_PCR_DS_HIGH);
|
px_pcr->Port[pinpos] &= ~(Px_PCR_DS_HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure Open Drain selections bit
|
|
||||||
if(GPIO_InitStruct->GPIO_Pad & Px_PCR_OD)
|
|
||||||
{
|
|
||||||
px_pcr->Port[pinpos] |= Px_PCR_OD;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
px_pcr->Port[pinpos] &= ~(Px_PCR_OD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure Input buffer enable selection bit
|
// Configure Input buffer enable selection bit
|
||||||
if(GPIO_InitStruct->GPIO_Pad & Px_PCR_IE)
|
if(GPIO_InitStruct->GPIO_Pad & Px_PCR_IE)
|
||||||
{
|
{
|
||||||
|
@ -154,7 +137,7 @@ void HAL_GPIO_StructInit(GPIO_InitTypeDef* GPIO_InitStruct)
|
||||||
{
|
{
|
||||||
GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
|
GPIO_InitStruct->GPIO_Pin = GPIO_Pin_All;
|
||||||
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN;
|
GPIO_InitStruct->GPIO_Mode = GPIO_Mode_IN;
|
||||||
GPIO_InitStruct->GPIO_Pad = (GPIOPad_TypeDef)(GPIO_PuPd_UP);
|
GPIO_InitStruct->GPIO_Pad = (GPIOPad_TypeDef)(GPIO_SUMMIT|GPIO_IE|GPIO_PuPd_UP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -232,13 +215,27 @@ void HAL_GPIO_ResetBits(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
|
||||||
|
|
||||||
void HAL_GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
|
void HAL_GPIO_WriteBit(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, BitAction BitVal)
|
||||||
{
|
{
|
||||||
|
uint32_t temp_gpio_lb;
|
||||||
|
uint32_t temp_gpio_ub;
|
||||||
|
|
||||||
/* Check the parameters */
|
/* Check the parameters */
|
||||||
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
|
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
|
||||||
assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
|
assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
|
||||||
assert_param(IS_GPIO_BIT_ACTION(BitVal));
|
assert_param(IS_GPIO_BIT_ACTION(BitVal));
|
||||||
|
|
||||||
(GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = BitVal;
|
temp_gpio_lb = (GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]);
|
||||||
(GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = BitVal;
|
temp_gpio_ub = (GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]);
|
||||||
|
|
||||||
|
if( BitVal == Bit_SET)
|
||||||
|
{
|
||||||
|
(GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = (temp_gpio_lb | GPIO_Pin);
|
||||||
|
(GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = (temp_gpio_ub | GPIO_Pin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
(GPIOx->LB_MASKED[(uint8_t)(GPIO_Pin)]) = (temp_gpio_lb & ~(GPIO_Pin));
|
||||||
|
(GPIOx->UB_MASKED[(uint8_t)((GPIO_Pin)>>8)]) = (temp_gpio_ub & ~(GPIO_Pin));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void HAL_GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
|
void HAL_GPIO_Write(GPIO_TypeDef* GPIOx, uint16_t PortVal)
|
||||||
|
@ -254,6 +251,7 @@ void HAL_PAD_AFConfig(PAD_Type Px, uint16_t GPIO_Pin, PAD_AF_TypeDef P_AF)
|
||||||
int i;
|
int i;
|
||||||
uint16_t idx =0x1;
|
uint16_t idx =0x1;
|
||||||
assert_param(IS_PAD_Type(Px));
|
assert_param(IS_PAD_Type(Px));
|
||||||
|
assert_param(IS_GET_GPIO_PIN(GPIO_Pin));
|
||||||
|
|
||||||
for(i=0;i<16;i++)
|
for(i=0;i<16;i++)
|
||||||
{
|
{
|
||||||
|
@ -262,29 +260,25 @@ void HAL_PAD_AFConfig(PAD_Type Px, uint16_t GPIO_Pin, PAD_AF_TypeDef P_AF)
|
||||||
if(Px == PAD_PA)
|
if(Px == PAD_PA)
|
||||||
{
|
{
|
||||||
assert_param(IS_PA_NUM(i));
|
assert_param(IS_PA_NUM(i));
|
||||||
//PA_AFSR->Port[i] &= ~(0x03ul);
|
PA_AFSR->Port[i] &= ~(0x03ul);
|
||||||
//PA_AFSR->Port[i] |= P_AF;
|
|
||||||
PA_AFSR->Port[i] = P_AF;
|
PA_AFSR->Port[i] = P_AF;
|
||||||
}
|
}
|
||||||
else if(Px == PAD_PB)
|
else if(Px == PAD_PB)
|
||||||
{
|
{
|
||||||
assert_param(IS_PB_NUM(i));
|
assert_param(IS_PB_NUM(i));
|
||||||
//PB_AFSR->Port[i] &= ~(0x03ul);
|
PB_AFSR->Port[i] &= ~(0x03ul);
|
||||||
//PB_AFSR->Port[i] |= P_AF;
|
|
||||||
PB_AFSR->Port[i] = P_AF;
|
PB_AFSR->Port[i] = P_AF;
|
||||||
}
|
}
|
||||||
else if(Px == PAD_PC)
|
else if(Px == PAD_PC)
|
||||||
{
|
{
|
||||||
assert_param(IS_PC_NUM(i));
|
assert_param(IS_PC_NUM(i));
|
||||||
//PC_AFSR->Port[i] &= ~(0x03ul);
|
PC_AFSR->Port[i] &= ~(0x03ul);
|
||||||
//PC_AFSR->Port[i] |= P_AF;
|
|
||||||
PC_AFSR->Port[i] = P_AF;
|
PC_AFSR->Port[i] = P_AF;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert_param(IS_PD_NUM(i));
|
assert_param(IS_PD_NUM(i));
|
||||||
//PD_AFSR->Port[i] &= ~(0x03ul);
|
PD_AFSR->Port[i] &= ~(0x03ul);
|
||||||
//PD_AFSR->Port[i] |= P_AF;
|
|
||||||
PD_AFSR->Port[i] = P_AF;
|
PD_AFSR->Port[i] = P_AF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,13 @@ typedef enum
|
||||||
GPIO_PuPd_UP = Px_PCR_PUPD_UP,
|
GPIO_PuPd_UP = Px_PCR_PUPD_UP,
|
||||||
GPIO_PuPd_DOWN = Px_PCR_PUPD_DOWN,
|
GPIO_PuPd_DOWN = Px_PCR_PUPD_DOWN,
|
||||||
GPIO_PuPd_Default = 0x0ul,
|
GPIO_PuPd_Default = 0x0ul,
|
||||||
|
GPIO_DS = Px_PCR_DS_HIGH,
|
||||||
|
GPIO_IE = Px_PCR_IE,
|
||||||
|
GPIO_SUMMIT = Px_PCR_CS_SUMMIT
|
||||||
}GPIOPad_TypeDef;
|
}GPIOPad_TypeDef;
|
||||||
|
|
||||||
|
#define IS_GPIO_PUPD(PUPD) (((PUPD) == GPIO_PuPd_UP) || ((PUPD) == GPIO_PuPd_DOWN))
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t GPIO_Pin;
|
uint32_t GPIO_Pin;
|
||||||
|
@ -77,6 +82,18 @@ typedef struct
|
||||||
GPIOPad_TypeDef GPIO_Pad;
|
GPIOPad_TypeDef GPIO_Pad;
|
||||||
}GPIO_InitTypeDef;
|
}GPIO_InitTypeDef;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Falling = 0,
|
||||||
|
Rising = 1
|
||||||
|
}GPIOPol_TypeDef;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
Reset = 0,
|
||||||
|
Set = 1
|
||||||
|
}GPIOSet_TypeDef;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Bit_RESET = 0,
|
Bit_RESET = 0,
|
||||||
|
@ -84,7 +101,7 @@ typedef enum
|
||||||
}BitAction;
|
}BitAction;
|
||||||
|
|
||||||
|
|
||||||
#define IS_PAD_TYPE(Px) (((Px) == PAD_PA) || ((Px) == PAD_PB) \
|
#define IS_PAD_TYPE(Px) (((Px) == PAD_PA) || ((Px) == PAD_PB) || \
|
||||||
((Px) == PAD_PC) || ((Px) == PAD_PD))
|
((Px) == PAD_PC) || ((Px) == PAD_PD))
|
||||||
|
|
||||||
#define IS_PA_NUM(NUM) (((NUM)>=0) && ((NUM)<16))
|
#define IS_PA_NUM(NUM) (((NUM)>=0) && ((NUM)<16))
|
||||||
|
|
|
@ -35,4 +35,5 @@ void mbed_sdk_init()
|
||||||
{
|
{
|
||||||
// Update the SystemCoreClock variable.
|
// Update the SystemCoreClock variable.
|
||||||
SystemInit();
|
SystemInit();
|
||||||
|
SysTick_Config((GetSystemClock()/1000));
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,11 +51,8 @@ extern "C"{
|
||||||
|
|
||||||
void DUALTIMER0_Handler(void)
|
void DUALTIMER0_Handler(void)
|
||||||
{
|
{
|
||||||
if(DUALTIMER_GetIntStatus(DUALTIMER0_0))
|
DUALTIMER_IntClear(DUALTIMER0_0);
|
||||||
{
|
us_ticker_irq_handler();
|
||||||
DUALTIMER_IntClear(DUALTIMER0_0);
|
|
||||||
us_ticker_irq_handler();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue