示例#1
0
文件: main.c 项目: Arcko/trochili
/*!
    \brief      main function
    \param[in]  none
    \param[out] none
    \retval     none
*/
int main(void)
{
    can_parameter_struct            can_init_parameter;
    can_filter_parameter_struct     can_filter_parameter;

    receive_flag = RESET;
    /* configure Tamper key */
    gd_eval_keyinit(KEY_TAMPER, KEY_MODE_GPIO);
    /* configure GPIO */
    gpio_config();
    /* configure USART */
    gd_eval_COMinit(EVAL_COM2);
    /* configure NVIC */
    nvic_config();
    /* configure leds */
    led_config();
    /* set all leds off */
    gd_eval_ledoff(LED1);
    gd_eval_ledoff(LED2);
    gd_eval_ledoff(LED3);
    gd_eval_ledoff(LED4);
    /* initialize CAN */
    can_networking_init(can_init_parameter, can_filter_parameter);
    /* enable phy */
#ifdef CAN0_USED 
    can_phy_enable(CANX);
#endif
    /* enable CAN receive FIFO0 not empty interrupt */
    can_interrupt_enable(CANX, CAN_INTEN_RFNEIE0);
    
    /* initialize transmit message */
    transmit_message.can_tx_sfid = 0x321;
    transmit_message.can_tx_efid = 0x01;
    transmit_message.can_tx_ft = CAN_FT_DATA;
    transmit_message.can_tx_ff = CAN_FF_STANDARD;
    transmit_message.can_tx_dlen = 1;
    printf("please press the Tamper key to transmit data!\r\n");
    while(1){
        /* waiting for the Tamper key pressed */
        while(0 == gd_eval_keygetstate(KEY_TAMPER)){
            /* if transmit_number is 0x10, set it to 0x00 */
            if(transmit_number == 0x10){
                transmit_number = 0x00;
            }else{
                transmit_message.can_tx_data[0] = transmit_number++;
                printf("transmit data: %x\r\n", transmit_message.can_tx_data[0]);
                /* transmit message */
                can_transmit_message(CANX, &transmit_message);
                delay();
                /* waiting for Tamper key up */
                while(0 == gd_eval_keygetstate(KEY_TAMPER));
            }
        }
        if(SET == receive_flag){
            gd_eval_ledtoggle(LED1);
            receive_flag = RESET;
            printf("recive data: %x\r\n", receive_message.can_rx_data[0]);
        }
    } 
}
示例#2
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);
            }
        }
    }
}
示例#3
0
/*****************************************************************************
 Function    : LOS_EvbGetKeyVal
 Description : Get GIOP Key value
 Input       : None
 Output      : None
 Return      : None
 *****************************************************************************/
unsigned int LOS_EvbGetKeyVal(int KeyNum)
{
    unsigned int KeyVal = LOS_GPIO_ERR;
    
    //add you code here.
	KeyVal = gd_eval_keygetstate(USER_KEY);
    
    return KeyVal;
}