71 lines
1.1 KiB
C
71 lines
1.1 KiB
C
#include <avr/interrupt.h>
|
|
#include <avr/io.h>
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
#include "timer.h"
|
|
#include "app.h"
|
|
#include "uart.h"
|
|
|
|
void setup() {
|
|
USART_Init(MYUBRR);
|
|
|
|
DDRD = 0b00001111;
|
|
PORTD = 0b11110000;
|
|
|
|
DDRC = 0b111111;
|
|
PORTC = 0b001111;
|
|
}
|
|
|
|
|
|
void countKeysPressedTime(char *keys) {
|
|
|
|
for (int i = 0; i < 16; i++) {
|
|
keyTimeMap[i].key = i;
|
|
if (keys[i] == 0) {
|
|
keyTimeMap[i].time += 5;
|
|
} else {
|
|
keyTimeMap[i].time = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
//void debounce(char *keys) {
|
|
//if (ms % 5 != 0) return;
|
|
//isDebounced = 0;
|
|
//checkKeysState(newKeysState);
|
|
//
|
|
//for (int i = 0; i < 16; i++) {
|
|
//if (newKeysState[i] != keys[i]) {
|
|
//confidenceLevel = 0;
|
|
//}
|
|
//}
|
|
//
|
|
//if (confidenceLevel < 6) confidenceLevel++;
|
|
//if (confidenceLevel == 5) {
|
|
//for (int i = 0; i < 16; i++) {
|
|
//debouncedKeys[i] = keys[i];
|
|
//}
|
|
//isDebounced = 1;
|
|
//confidenceLevel = 0;
|
|
//}
|
|
//}
|
|
|
|
void loop() {
|
|
|
|
}
|
|
|
|
int main(void) {
|
|
|
|
setup();
|
|
while(1) {
|
|
|
|
USART_Transmit(0x6F);
|
|
//for(volatile long i = 0; i < 100000; i++){};
|
|
loop();
|
|
}
|
|
}
|
|
|
|
int fputc(int ch, FILE *stream){
|
|
USART_Transmit(ch);
|
|
}
|