Пример #1
0
Файл: sw.c Проект: coocox/Mplib
/*******************************************************************************
* Function Name  : SW_Init
* Description    : Initialize the GPIO to SW 
* Input          : None 
* Return         : None.
*******************************************************************************/
void SW_Init(void)
{
    GPIO_SetInput(GPIO_PH, 0x03U);
    GPIO_SetInput(GPIO_PK, 0x03U);

    GPIO_SetOutput(SWS_DATA_PORT, GPIO_BIT_2);
}
Пример #2
0
Файл: sw.c Проект: coocox/Mplib
/*******************************************************************************
* Function Name  : SW_Init
* Description    : Initialize the GPIO to SW 
* Input          : None 
* Return         : None.
*******************************************************************************/
void SW_Init(void)
{
    GPIO_SetInput(GPIO_PE, GPIO_BIT_2);
    GPIO_SetInput(GPIO_PJ, GPIO_BIT_7);
    GPIO_SetInput(GPIO_PK, GPIO_BIT_0);
    GPIO_SetInput(GPIO_PK, GPIO_BIT_1);
}
Пример #3
0
/*******************************************************************************
* Function Name  : SW_Init
* Description    : Initialize the GPIO to SW 
* Input          : None 
* Return         : None.
*******************************************************************************/
void SW_Init(void)
{
    GPIO_SetInput(GPIO_PI, GPIO_BIT_0);
    GPIO_SetInput(GPIO_PI, GPIO_BIT_1);
    GPIO_SetInput(GPIO_PI, GPIO_BIT_2);
    GPIO_SetInput(GPIO_PI, GPIO_BIT_3);
    
    GPIO_SetOutput(GPIO_PJ, GPIO_BIT_2);
}
void Commands_SetPinConfig(uint8_t* data)
{
	switch (data[1])
	{
		case MakeDigitalInput:
			GPIO_SetInput(data[0], data[2]);
			pinConfigs[data[0]] = DigitalInput;
			break;
		case MakeDigitalOutput:
			GPIO_SetOutput(data[0]);
			pinConfigs[data[0]] = DigitalOutput;
			break;
		case SetDigitalValue:
			GPIO_WriteValue(data[0], data[2]);
			break;
		case MakeAnalogInput:
			ADC_SetInput(data[0]);
			pinConfigs[data[0]] = AnalogInput;
			break;
		case MakePWMPin:
			PWM_SetOutput(data[0], data[2]);
			break;
		case SetPWMValue:
			PWM_SetValue(data[0], data[2], data[3]);
			break;


	}
}
Пример #5
0
/**
  * @brief  TMRB_PPG demo
  * @param  None
  * @retval None
  */
void Example_TimerPpg(void)
{
    uint8_t Rate = 0U;
    uint32_t Duty[5] = { 0x8CAU, 0x753U, 0x4E2U, 0x271U, 0xFAU };       /* duty: 10%, 25%, 50%, 75%, 90% */
    uint8_t keyvalue;

    TMRB_InitTypeDef m_tmrb;
    TMRB_FFOutputTypeDef PPGFFInital;

    GPIO_SetInput(KEYPORT, GPIO_BIT_0); /* set KEY port to input */ 

    /* Set PF1 as TB7OUT for PPG output */
    GPIO_SetOutput(GPIO_PF, GPIO_BIT_1);
    GPIO_EnableFuncReg(GPIO_PF, GPIO_FUNC_REG_1, GPIO_BIT_1);
    GPIO_SetPullUp(GPIO_PF, GPIO_BIT_1, ENABLE);

    m_tmrb.Mode = TMRB_INTERVAL_TIMER;
    m_tmrb.ClkDiv = TMRB_CLK_DIV_8;
    m_tmrb.UpCntCtrl = TMRB_AUTO_CLEAR;
    m_tmrb.Cycle = TMRB7TIME;   /* T = 250us */
    m_tmrb.Duty = Duty[Rate];
    PPGFFInital.FlipflopCtrl = TMRB_FLIPFLOP_CLEAR;
    PPGFFInital.FlipflopReverseTrg = TMRB_FLIPFLOP_MATCH_CYCLE | TMRB_FLIPFLOP_MATCH_DUTY;

    TMRB_Enable(TSB_TB7);
    TMRB_Init(TSB_TB7, &m_tmrb);
    TMRB_SetFlipFlop(TSB_TB7, &PPGFFInital);
    TMRB_SetDoubleBuf(TSB_TB7, ENABLE, TMRB_WRITE_REG_SEPARATE);        /* enable double buffer */
    TMRB_SetRunState(TSB_TB7, TMRB_RUN);

    do {                        /* wait if key is pressed */
        keyvalue = GPIO_ReadDataBit(KEYPORT, GPIO_BIT_0);
    } while (GPIO_BIT_VALUE_1 == keyvalue);

    delay(0xFFFU);              /* noise cancel */

    while (1) {
        do {                    /* wait if key is released */
            keyvalue = GPIO_ReadDataBit(KEYPORT, GPIO_BIT_0);
        } while (GPIO_BIT_VALUE_0 == keyvalue);

        delay(0xFFFU);          /* noise cancel */

        Rate++;
        if (Rate >= DUTYMAX) {  /* change duty rate */
            Rate = DUTYINIT;
        } else {
            /* Do nothing */
        }

        TMRB_ChangeDuty(TSB_TB7, Duty[Rate]); /* change duty rate */

        do {                    /* wait if key is pressed */
            keyvalue = GPIO_ReadDataBit(KEYPORT, GPIO_BIT_0);
        } while (GPIO_BIT_VALUE_1 == keyvalue);

        delay(0xFFFU);          /* noise cancel */
    }
}
Пример #6
0
/**
  * @brief  CAN port initialization
  * @param  None.
  * @retval None.
  */
void CAN_PortInit(void)
{
    GPIO_SetOutput(GPIO_PE, GPIO_BIT_4);        /* Set TX pin as output */
    GPIO_SetInput(GPIO_PE, GPIO_BIT_5); /* Set RX pin as input */
    GPIO_EnableFuncReg(GPIO_PE, GPIO_FUNC_REG_3, (uint8_t) (GPIO_BIT_4 | GPIO_BIT_5));  /* Enable TX and RX pin functions */
    GPIO_SetOpenDrain(GPIO_PE, GPIO_BIT_4, DISABLE);    /* Set TX pin as CMOS output */
    GPIO_SetPullUp(GPIO_PE, (uint8_t) (GPIO_BIT_4 | GPIO_BIT_5), DISABLE);      /* Disable pull-ups for CAN pins */
}
Пример #7
0
Файл: sw.c Проект: coocox/Mplib
/*******************************************************************************
* Function Name  : SW_Init
* Description    : Initialize the GPIO to SW 
* Input          : None.
* Return         : None.
*******************************************************************************/
void SW_Init(void)
{
    GPIO_SetInput(GPIO_PA, GPIO_BIT_0 | GPIO_BIT_1 | GPIO_BIT_2);
}