change interrupt routine
This commit is contained in:
parent
bf464bcd00
commit
6a27fb816b
25
src/switch.cpp
Normal file
25
src/switch.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
/*
|
||||
void switch_interrupt() {
|
||||
unsigned long currentEvent = millis();
|
||||
|
||||
if ((lastEvent == 0) || (lastEvent + DEBOUNCING_DEAD_TIME < currentEvent)) {
|
||||
lastEvent = currentEvent;
|
||||
|
||||
switchState = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool getAndResetSwitchState() {
|
||||
bool res = false;
|
||||
|
||||
noInterrupts();
|
||||
res = switchState;
|
||||
switchState = false;
|
||||
interrupts();
|
||||
|
||||
return res;
|
||||
}
|
||||
*/
|
15
src/time.cpp
15
src/time.cpp
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* time.c
|
||||
*
|
||||
* Created on: 20.05.2014
|
||||
* Created on: 17.01.2016
|
||||
* Author: wn
|
||||
*/
|
||||
#include <msp430g2553.h>
|
||||
@ -11,13 +11,16 @@
|
||||
#include "time.h"
|
||||
|
||||
|
||||
volatile uint16_t timestamp;
|
||||
volatile uint16_t timestamp = 0;
|
||||
volatile uint32_t tickCnt = 0;
|
||||
const uint16_t TICK = 1024;
|
||||
uint16_t pwmVal = 128;
|
||||
volatile uint16_t onTime = 500;
|
||||
volatile uint16_t offTime = 200;
|
||||
|
||||
ISR(TIMER0_A0, TA0_ISR) {
|
||||
tickCnt++;
|
||||
|
||||
static uint8_t state0 = 0;
|
||||
static uint8_t state1 = 0;
|
||||
|
||||
@ -77,4 +80,12 @@ void timeInit() {
|
||||
}
|
||||
|
||||
|
||||
uint32_t ticks() {
|
||||
__disable_interrupt();
|
||||
uint32_t t = tickCnt;
|
||||
__enable_interrupt();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* time.h
|
||||
*
|
||||
* Created on: 20.05.2014
|
||||
* Created on: 17.01.2016
|
||||
* Author: wn
|
||||
*/
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
|
||||
|
||||
void timeInit();
|
||||
uint32_t ticks();
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user