/**
 * ENSICAEN
 * 6 Boulevard Maréchal Juin
 * F-14050 Caen Cedex
 *
 * This file is owned by ENSICAEN students. No portion of this
 * document may be reproduced, copied or revised without written
 * permission of the authors.
 */

/**
 * @author  Dimitri Boudier <dimitri.boudier@ensicaen.fr>
 * @version 1.0.q3 - 2024-04-22
 *
 * @note 	This file exists in 8 different version, one for each training question
 */

/**
 * @file    main.c
 * @brief   Correction of the training lab exam
 */

#include <bsplib.h>


/** Global variables */
uInt8_t     minuteur_actif = FALSE;
uInt16_t    valeur_initiale_minuteur = 5;
uInt16_t    valeur_courante_minuteur;


/** High-priority Interrupt Service Routine */
void __interrupt(high_priority) isr_high (void)
{ 
    /** @todo */
}


/** Low-priority Interrupt Service Routine */
void __interrupt(low_priority) isr_low (void)
{
    /** @todo */
    // Question 3
    if( PIR0 & 0x20 )
    {
        PIR0 &= ~0x20;
        timer0_reload( 15625 );
        led2_toggle();
    }
}


/** main function */
void main(void)
{    
    /* system initialization */
    
    // Question 2
    uart1_init( 115200 );
    uart1_puts( "\r\n\r\n### DEMARRAGE DE L'APPPLICATION MINUTEUR" );
    
    // Question 3
    led2_init();
    led3_init();
    led4_init();
    led5_init();
    led2_off();
    led3_off();
    led4_off();
    led5_off();
    
    timer0_init( 15625 );   // Attention, la valeur dépend du prescaler choisi (ici 1:1024)
    
    INTCON |= 0xE0;

    /* application's main loop */
    while (1)
    {
        
    }       
}
