Added semi-HW 1-wire realisation (alpha-version)

This commit is contained in:
eddyem
2015-07-16 18:01:59 +03:00
parent 21eebc4306
commit 5433c2ad50
27 changed files with 2232 additions and 7 deletions

View File

@@ -69,17 +69,26 @@ void SysTick_init(){
void check_btns(){
static uint8_t oldstate[2] = {1,1}; // old buttons state
uint8_t newstate[2], i;
static uint32_t Old_timer[2] = {0,0};
newstate[0] = gpio_get(BTNS_PORT, BTN_S2_PIN) ? 1 : 0;
newstate[1] = gpio_get(BTNS_PORT, BTN_S3_PIN) ? 1 : 0;
for(i = 0; i < 2; i++){
uint8_t new = newstate[i];
if(new != oldstate[i]){
P("Button S");
usb_send('2' + i);
if(new) P("pressed");
else P("released");
newline();
oldstate[i] = new;
// pause for 60ms
uint32_t O = Old_timer[i];
if(!O){
if(Timer - O > 60 || O > Timer){
P("Button S");
usb_send('2' + i);
if(new) P("released");
else P("pressed");
newline();
oldstate[i] = new;
Old_timer[i] = 0;
}
}
else if(new != oldstate[i]){
Old_timer[i] = Timer;
}
}
}

Binary file not shown.