diff --git a/module03/ex00/bitmanip.h b/module03/ex00/bitmanip.h index 4df44d1..bf9c297 100644 --- a/module03/ex00/bitmanip.h +++ b/module03/ex00/bitmanip.h @@ -41,13 +41,19 @@ #define D4 4 #define SW1 2 #define SW2 4 +#define D5B 3 +#define D5R 5 +#define D5G 6 // Elements (port, bit) -#define LED1 (B, D1) -#define LED2 (B, D2) -#define LED3 (B, D3) -#define LED4 (B, D4) -#define BUTTON1 (D, SW1) -#define BUTTON2 (D, SW2) +#define LED1 (B, D1) +#define LED2 (B, D2) +#define LED3 (B, D3) +#define LED4 (B, D4) +#define BUTTON1 (D, SW1) +#define BUTTON2 (D, SW2) +#define RGB5_BLUE (D, D5B) +#define RGB5_RED (D, D5R) +#define RGB5_GEEN (D, D5G) #endif // BITMANIP_H \ No newline at end of file diff --git a/module03/ex00/interrupt.h b/module03/ex00/interrupt.h index dccc1c5..9668ef7 100644 --- a/module03/ex00/interrupt.h +++ b/module03/ex00/interrupt.h @@ -2,7 +2,7 @@ #define INTERRUPT_H // 7.3.1 : SREG – AVR Status Register -#define ENABLE_GLOBAL_INTERRUPT (1<<7) -#define DISABLE_GLOBAL_INTERRUPT (0<<7) +#define ENABLE_GLOBAL_INTERRUPT (1< #include -#include // https://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html +#include #include "utils.h" #include "bitmanip.h" -#include "timer.h" -#include "usart.h" -#include "interrupt.h" -// ask for username and password -int main() { - uart_init(); - ask_for_username(); - - SREG |= ENABLE_GLOBAL_INTERRUPT; // 7.3.1 : Status Register, bit 7 : I – Global Interrupt Enable - - while(1); +void rgb_d5_roll_colors() { + MODE_OUTPUT(RGB5_RED); + MODE_OUTPUT(RGB5_GEEN); + MODE_OUTPUT(RGB5_BLUE); + while(1) { + SET_ELEM(RGB5_RED); + _delay_ms(1000); + CLEAR_ELEM(RGB5_RED); + SET_ELEM(RGB5_GEEN); + _delay_ms(1000); + CLEAR_ELEM(RGB5_GEEN); + SET_ELEM(RGB5_BLUE); + _delay_ms(1000); + CLEAR_ELEM(RGB5_BLUE); + } +} + +// led RGB D5 must turns on in red then green then blue in a loop +int main() { + + while(1) { + rgb_d5_roll_colors(); + } }