main.c
#include "main.h"
#include "mcu_ini.h"
uint8_t Mode = 0;
uint16_t Mode_count = 0;
uint8_t Mode_new = 0;
void SysTick_Handler(void) //1ms
{
if(Mode_count > 0)
{
Mode_count--;
}
}
int main(void)
{
LEDs_ini();
SysTick_Config(SystemCoreClock/1000);
Mode = MODE_RED;
while(1)
{
if(Mode == MODE_RED)
{
if(Mode_new == 1)
{
RED_ON();
Mode_new = 0;
Mode_count = DELAY;
}
if(Mode_count == 0)
{
RED_OFF();
Mode = MODE_BLUE;
Mode_new = 1;
}
}
else if(Mode == MODE_BLUE)
{
if(Mode_new == 1)
{
BLUE_ON();
Mode_new = 0;
Mode_count = DELAY;
}
if(Mode_count == 0)
{
BLUE_OFF();
Mode = MODE_GREEN;
Mode_new = 1;
}
}
else if(Mode == MODE_GREEN)
{
if(Mode_new == 1)
{
GREEN_ON();
Mode_new = 0;
Mode_count = DELAY;
}
if(Mode_count == 0)
{
GREEN_OFF();
Mode = MODE_YELLOW;
Mode_new = 1;
}
}
else if(Mode == MODE_YELLOW)
{
if(Mode_new == 1)
{
YELLOW_ON();
Mode_new = 0;
Mode_count = DELAY;
}
if(Mode_count == 0)
{
YELLOW_OFF();
Mode = MODE_RED;
Mode_new = 1;
}
}
}
}