|
|
|
@ -3,6 +3,7 @@
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include <avr/eeprom.h>
|
|
|
|
#include <avr/eeprom.h>
|
|
|
|
#include <util/delay.h>
|
|
|
|
#include <util/delay.h>
|
|
|
|
|
|
|
|
#include <util/atomic.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <usbdrv/usbdrv.h>
|
|
|
|
#include <usbdrv/usbdrv.h>
|
|
|
|
@ -14,6 +15,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
static uint8_t newThermoData = 1;
|
|
|
|
static uint8_t newThermoData = 1;
|
|
|
|
static uint16_t thermoData[] = {1024, 814, 2475, 2243};
|
|
|
|
static uint16_t thermoData[] = {1024, 814, 2475, 2243};
|
|
|
|
|
|
|
|
volatile uint16_t timer1_acc;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SOFTTIMERNUMS 4
|
|
|
|
|
|
|
|
uint16_t softtimer_last[SOFTTIMERNUMS];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void softtimer_reset(uint8_t timernum){
|
|
|
|
|
|
|
|
softtimer_last[SOFTTIMERNUMS] = timer1_acc;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t softtimer(uint8_t timernum, uint16_t interval){
|
|
|
|
|
|
|
|
uint16_t timer1_acc_tmp = timer1_acc; // because of volatile
|
|
|
|
|
|
|
|
if((uint16_t)(timer1_acc_tmp - (uint16_t)(softtimer_last[timernum]) >= interval )){
|
|
|
|
|
|
|
|
softtimer_last[timernum] = timer1_acc_tmp;
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define SOFTTIMER(n,a) if(softtimer((n),(a*4)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void hardinit() {
|
|
|
|
void hardinit() {
|
|
|
|
@ -100,7 +123,9 @@ int __attribute__((noreturn)) main(void) {
|
|
|
|
for(;;){
|
|
|
|
for(;;){
|
|
|
|
usbPoll();
|
|
|
|
usbPoll();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SOFTTIMER(1,100){
|
|
|
|
updateDisplay();
|
|
|
|
updateDisplay();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
thermoData[0]=thermoData[0]+5;
|
|
|
|
thermoData[0]=thermoData[0]+5;
|
|
|
|
thermoData[1]=thermoData[1]+15;
|
|
|
|
thermoData[1]=thermoData[1]+15;
|
|
|
|
@ -108,8 +133,6 @@ int __attribute__((noreturn)) main(void) {
|
|
|
|
thermoData[3]=thermoData[3]+18;
|
|
|
|
thermoData[3]=thermoData[3]+18;
|
|
|
|
i++; if(i%200 == 0) newThermoData = 1;
|
|
|
|
i++; if(i%200 == 0) newThermoData = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
@ -119,3 +142,16 @@ int __attribute__((noreturn)) main(void) {
|
|
|
|
asm volatile ("out %1, %0\n" : "=r" (sreg_store) : "I" (_SFR_IO_ADDR(SREG)));
|
|
|
|
asm volatile ("out %1, %0\n" : "=r" (sreg_store) : "I" (_SFR_IO_ADDR(SREG)));
|
|
|
|
reti();
|
|
|
|
reti();
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
|
|
|
|
ISR(TIMER1_OVF_vect,ISR_NOBLOCK){
|
|
|
|
|
|
|
|
uint16_t temp;
|
|
|
|
|
|
|
|
temp=timer1_acc;
|
|
|
|
|
|
|
|
temp++;
|
|
|
|
|
|
|
|
ATOMIC_BLOCK(ATOMIC_FORCEON){
|
|
|
|
|
|
|
|
timer1_acc=temp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the ATOMIC is acutally only needed if timer1_acc is never read from an ISR, which
|
|
|
|
|
|
|
|
* is probably the case.
|
|
|
|
|
|
|
|
* ATOMIC_FORCEON: the ISR_NOBLOCK sets sei() a few cycles before.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|