예제 #1
0
파일: main.c 프로젝트: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    /* system clocks configuration */
    irc40k_config();
    systick_config();
  
    gd_eval_ledinit(LED2);
    gd_eval_keyinit(KEY_TAMPER,KEY_MODE_EXTI);
    delay_1ms(50);

    /* enable write access to FWDGT_PSC and FWDGT_RLD registers.
       FWDGT counter clock: 40KHz(IRC40K) / 64 = 0.625 KHz */
    fwdgt_config(625,FWDGT_PSC_DIV64);
    fwdgt_enable();

    /* check if the system has resumed from FWDGT reset */
    if (RESET != rcu_flag_get(RCU_FLAG_FWDGTRST)){
        gd_eval_ledon(LED2);
        rcu_reset_flag_clear();
      
        while(1);
    }else{
        gd_eval_ledoff(LED2);
    }

    while (1);
}
예제 #2
0
파일: main.c 프로젝트: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    gd_eval_ledinit(LED2);

    systick_config();

    while (1);
}
예제 #3
0
파일: main.c 프로젝트: ClarePhang/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    /* GPIO clock enable */
    rcu_periph_clock_enable(RCU_GPIOA);
    rcu_periph_clock_enable(RCU_GPIOB);
    rcu_periph_clock_enable(RCU_GPIOC);
    rcu_periph_clock_enable(RCU_GPIOF);

    /* delay time initialize */
    systick_config();

    /* configure the CEC peripheral */
    cec_config();

    /* configure the EXTI */
    gd_eval_keyinit(KEY_TAMPER, KEY_MODE_EXTI);

#ifdef GD32F130_150

    gd_eval_keyinit(KEY_USER, KEY_MODE_EXTI);

#elif defined(GD32F170_190)

    gd_eval_keyinit(KEY_WAKEUP, KEY_MODE_EXTI);

#endif /* GD32F130_150 */

    /* LED1 LED2 initialize */
    gd_eval_ledinit(LED1);
    gd_eval_ledinit(LED2);
    gd_eval_ledoff(LED1);
    gd_eval_ledoff(LED2);

    /* main loop */
    while(1) {
        /* wait receive data */
        while(rcvstatus==0);

        if(rcvstatus == 1) {
            if((rcvdata[1]==0xA5)&&(rcvdata[2]==0x5A)) {
                gd_eval_ledon(LED1);
                delay_1ms(10);
                gd_eval_ledoff(LED1);
            }
            if((rcvdata[1]==0x5A)&&(rcvdata[2]==0xA5)) {
                gd_eval_ledon(LED2);
                delay_1ms(10);
                gd_eval_ledoff(LED2);
            }
        }
        /* a reception error occured */
        rcvstatus = 0;
    }
}
예제 #4
0
파일: main.c 프로젝트: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    uint16_t num = 0;
    /* system clocks configuration */
    rcu_config();
    /* systick config: 1ms delay */
    systick_config();
    /* slcd interface configuration */
    slcd_seg_config();

    while(1){
        slcd_seg_number_display(num++);
        delay_1ms(1000);
    }
}
예제 #5
0
파일: main.c 프로젝트: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    systick_config();
    gd_eval_ledinit(LED1);
    gd_eval_keyinit(KEY_TAMPER,KEY_MODE_GPIO);

    while(1){
        /* check whether the button is pressed */
        if(RESET == gd_eval_keygetstate(KEY_TAMPER)){
            delay_1ms(100);
            /* check whether the button is pressed */
            if(RESET == gd_eval_keygetstate(KEY_TAMPER)){
                gd_eval_ledtoggle(LED1);
            }
        }
    }
}
예제 #6
0
파일: main.c 프로젝트: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{	  
    /* systick config */
    systick_config();
    /* led config */
    led_config();
    /* clock enable */
    rcu_periph_clock_enable(RCU_PMU);
    /* wakeup key config */
    gd_eval_keyinit(KEY_WAKEUP,KEY_MODE_GPIO);
    /* tamper key EXTI config */
    gd_eval_keyinit(KEY_TAMPER,KEY_MODE_EXTI);
    /* press wakeup key to enter deepsleep mode and use tamper key generate a exti interrupt to wakeup mcu */
    while(1){
        if(RESET == gpio_input_bit_get(WAKEUP_KEY_GPIO_PORT,WAKEUP_KEY_PIN))
            pmu_to_deepsleepmode(PMU_LDO_LOWPOWER,WFI_CMD);
    }
}
예제 #7
0
uint16_t _bsp_set_clock_configuration
(
    /* [IN] runtime clock configuration */
    const BSP_CLOCK_CONFIGURATION clock_configuration
)
{
    uint32_t    system_clock;
    uint16_t    cpu_error = ERR_OK;

    cpu_error = Cpu_SetClockConfiguration((uint8_t)clock_configuration);
    if (cpu_error != ERR_OK)    {
        return cpu_error;
    }

    /* Get system clock for active clock configuration */
    system_clock = _cm_get_clock(clock_configuration, CM_CLOCK_SOURCE_CORE);

    systick_config(system_clock, BSP_ALARM_FREQUENCY);

    return ERR_OK;
}
예제 #8
0
static void systick_init
(
        void
)
{

    /* Get system clock for active clock configuration */
    uint32_t system_clock = _cm_get_clock(_cm_get_clock_configuration(), CM_CLOCK_SOURCE_CORE);

#if BSP_ALARM_FREQUENCY == 0
    #error Wrong definition of BSP_ALARM_FREQUENCY
#endif

    systick_config(system_clock, BSP_ALARM_FREQUENCY);

    SYST_CSR = 7;

    /* SVCall priority*/
    SCB_SHPR2 |= 0x10000000;
    /* SysTick priority*/
    SCB_SHPR3 |= SCB_SHPR3_PRI_15(CORTEX_PRIOR(BSP_TIMER_INTERRUPT_PRIORITY));
}