2021-10-21 19:55:33 +02:00
|
|
|
|
#include <avr/io.h>
|
|
|
|
|
|
2021-10-28 19:24:52 +02:00
|
|
|
|
void
|
|
|
|
|
Taster_init (void){
|
2021-11-11 01:33:55 +01:00
|
|
|
|
DDRD &= ~(0b111<<5); /* Set bit 5-7 of Data Direction Register D as input */
|
|
|
|
|
DDRC &= ~(1<<2); /* Set bit 2 of Data Direction Register C as input */
|
2021-10-21 19:55:33 +02:00
|
|
|
|
|
2021-11-11 01:33:55 +01:00
|
|
|
|
PORTD |= (0b111<<5); /* Initialize bit 5-7 of PORTD as for pull up resistor */
|
|
|
|
|
PORTC |= (1<<PINC2); /* Initialize bit 2 of PORTC as for pull up resistor */
|
|
|
|
|
|
|
|
|
|
/** Disable JTAG so Pin 2 of PORTC can be used as a GPIO
|
|
|
|
|
* Command needs to be run twice - see MCU Control Register Description (23.8.1)
|
|
|
|
|
* Bits 7 <EFBFBD> JTD: JTAG Interface Disable
|
|
|
|
|
* [..] The application software must write this bit to the desired value
|
|
|
|
|
* twice within four cycles to change its value. [...]
|
|
|
|
|
*/
|
|
|
|
|
MCUCR |= (1<<JTD);
|
2021-11-11 18:30:45 +01:00
|
|
|
|
MCUCR |= (1<<JTD);
|
2021-10-21 19:55:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-10-28 19:24:52 +02:00
|
|
|
|
uint8_t
|
|
|
|
|
Taster1_get (void){
|
2022-01-20 17:22:50 +01:00
|
|
|
|
/* Check if pin is low
|
|
|
|
|
-> low active pin
|
|
|
|
|
-> button is pressed
|
|
|
|
|
-> return 1 */
|
2021-10-28 17:11:55 +02:00
|
|
|
|
return ((PIND & (1<<PIND7)) == 0);
|
2021-10-21 19:55:33 +02:00
|
|
|
|
}
|
2022-01-20 17:22:50 +01:00
|
|
|
|
|
2021-10-28 19:24:52 +02:00
|
|
|
|
uint8_t
|
|
|
|
|
Taster2_get (void){
|
2021-10-28 17:11:55 +02:00
|
|
|
|
return ((PIND & (1<<PIND6)) == 0);
|
2021-10-21 19:55:33 +02:00
|
|
|
|
}
|
2022-01-20 17:22:50 +01:00
|
|
|
|
|
2021-10-28 19:24:52 +02:00
|
|
|
|
uint8_t
|
|
|
|
|
Taster3_get (void){
|
2021-10-28 17:11:55 +02:00
|
|
|
|
return ((PIND & (1<<PIND5)) == 0);
|
2021-10-21 19:55:33 +02:00
|
|
|
|
}
|
2022-01-20 17:22:50 +01:00
|
|
|
|
|
2021-10-28 19:24:52 +02:00
|
|
|
|
uint8_t
|
|
|
|
|
Taster4_get (void){
|
2021-10-28 17:11:55 +02:00
|
|
|
|
return ((PINC & (1<<PINC2)) == 0);
|
2021-10-21 19:55:33 +02:00
|
|
|
|
}
|