This commit is contained in:
hugo LAMY
2025-03-10 10:19:42 +01:00
parent 7459a2155c
commit 73bb93d96f
3 changed files with 38 additions and 20 deletions

View File

@@ -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

View File

@@ -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<<SREG_I)
#define DISABLE_GLOBAL_INTERRUPT (0<<SREG_I)
#endif // INTERRUPT_H

View File

@@ -1,20 +1,32 @@
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h> // https://www.nongnu.org/avr-libc/user-manual/group__avr__interrupts.html
#include <avr/interrupt.h>
#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();
}
}