Exemple #1
0
void main(void)
{
    _U08 key;

    System_EnablePLL(); /*Elevamos la frecuencia de operacion a 48MHz*/
    ANCON0 = 0XFF;      /*Desativamos las salidas analogicas*/
    ANCON1 = 0XFF;      /*Desativamos las salidas analogicas*/

    Timers_Init();                      /*inicializamos el driver para genere una interrupcion cada 5ms*/
    Timers_SetTime(0, 10/timers_ms);    /*recargamos el canal 0 con un valor de 10ms*/
    Keyboard_Init();                    /*Inicilizamos las entradas y salidas del teclado*/
    Gpios_WriteTris(GPIOS_PORTB, 0x00); /*puerto B como salida*/
    Gpios_WritePort(GPIOS_PORTB, 0x00); /*limpiamos el puerto*/
    Keyboard_SetDebounce(0, 50);        /*500ms de debouncea a la tecla 0*/
    Keyboard_SetDebounce(4, 50);        /*500ms de debounce a la tecla 4*/
    Keyboard_SetDebounce(8, 50);        /*500ms de debounce a la tecla 8*/
    Keyboard_SetDebounce(12, 50);       /*500ms de debounce a la tecla 12*/
    __ENABLE_INTERRUPTS();              /*se habilitan las interrupciones globales con prioridad*/

    while (1)
    {
        if(Timers_u16GetTime(0) == 0)   /*preguntamos si la interrupcion decrmento hasta llegar a 0 el canal 0*/
        {
            Timers_SetTime(0, 10/timers_ms);/*se cumplen los 100ms asi que volvemos a recargar el mismo canal */
            Keyboard_Task();                /*poleamos poleamos el teclado matrizial*/
        }

        if(Keyboard_bIsPressed() == _TRUE)          /*preguntamos si se presiono alguna tecla*/
        {
            key = Keyboard_u8GetKey();              /*obtenemos cual tecla se presiono*/
            Gpios_WritePort(GPIOS_PORTB, key);     /*despliego el valor de la tecla en el puerto B*/
        }
    }
}
Exemple #2
0
int main(void)
{
    _U08 port = 0;  /*declaro variable para escribir en el puerto*/

    ANCON0 = 0XFF;  /*Desactivamos las entradas analogicas*/
    ANCON1 = 0XFF;  /*Desactivamos las entradas analogicas*/

    Gpios_WriteTris(GPIOS_PORTB, 0x00);         /*puerto B completo como salida*/

    while (1)
    {
        port ^= 0xff;                           /*invierto todo el valor del puerto*/
        Gpios_WritePort(GPIOS_PORTB, port);     /*escribo en el puerto B el valor invertido*/
        Delays_ms(500);                         /*retardo 500 ms para observar el estado de los leds*/

    }
}
Exemple #3
0
/**-----------------------------------------------------------------------------------------------*/
void _7segments_Init(void)
{
    Gpios_WriteTris(_7SEGMENTS_PORT, 0x00);
    Gpios_PinDirection(_7SEGMENTS_DIGI0_P, _7SEGMENTS_DIGI0_B, GPIOS_OUTPUT);
    Gpios_WritePin(_7SEGMENTS_DIGI0_P, _7SEGMENTS_DIGI0_B, DIGI_OFF);
    #if _7SEGMENTS_DIGI_N > 1
        Gpios_PinDirection(_7SEGMENTS_DIGI1_P, _7SEGMENTS_DIGI1_B, GPIOS_OUTPUT);
        Gpios_WritePin(_7SEGMENTS_DIGI1_P, _7SEGMENTS_DIGI1_B, DIGI_OFF);
    #endif
    #if _7SEGMENTS_DIGI_N > 2
        Gpios_PinDirection(_7SEGMENTS_DIGI2_P, _7SEGMENTS_DIGI2_B, GPIOS_OUTPUT);
        Gpios_WritePin(_7SEGMENTS_DIGI2_P, _7SEGMENTS_DIGI2_B, DIGI_OFF);
    #endif
    #if _7SEGMENTS_DIGI_N > 3
        Gpios_PinDirection(_7SEGMENTS_DIGI3_P, _7SEGMENTS_DIGI3_B, GPIOS_OUTPUT);
        Gpios_WritePin(_7SEGMENTS_DIGI3_P, _7SEGMENTS_DIGI3_B, DIGI_OFF);
    #endif
}