Merge branch 'master' of gitorious.ghostdub.de:avr/thermocouple

master
Matthias Merz 15 years ago
commit 76679b2d5f

@ -1,7 +1,7 @@
TODO für ersten funktionierenden Stand:
Hardware:
- Analogteil
# Analogteil
Software:
- I2C-Code
@ -11,10 +11,7 @@ Software:
Später:
- USB-Protokoll auf AVR
- USB-Client am Rechner
- Display-Code
- PT1000
- Digitalansteuerung für muxer/offsetkompensatoren
- Gehäuse
- Thermocouple-Buchsen
# Thermocouple-Buchsen

@ -74,8 +74,8 @@ int cnt, vid, pid;
}
rxValue = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
rxIndex = ((int)buffer[3] & 0xff) | (((int)buffer[2] & 0xff) << 8);
fprintf(stderr, "%3d.%02d*C||", rxValue/100, rxValue%100);
fprintf(stderr, "%3d.%02d*C\n", rxIndex/100, rxIndex%100);
fprintf(stderr, "%3d.%02d*C ", rxValue/100, rxValue%100);
fprintf(stderr, "%3d.%02d*C \n", rxIndex/100, rxIndex%100);
cnt = usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, 2, value, index, buffer, sizeof(buffer), 5000);
if(cnt < 0){
@ -83,8 +83,8 @@ int cnt, vid, pid;
}
rxValue = ((int)buffer[1] & 0xff) | (((int)buffer[0] & 0xff) << 8);
rxIndex = ((int)buffer[3] & 0xff) | (((int)buffer[2] & 0xff) << 8);
fprintf(stderr, "%3d.%02d*C||", rxValue/100, rxValue%100);
fprintf(stderr, "%3d.%02d*C\n", rxIndex/100, rxIndex%100);
fprintf(stderr, "%3d.%02d*C ", rxValue/100, rxValue%100);
fprintf(stderr, "%3d.%02d*C \n", rxIndex/100, rxIndex%100);
usb_close(handle);

@ -0,0 +1,26 @@
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-------------+ +-------------+ +-------------+ +-------------+
| OpCode | | Address | | ValueH | | ValueL |
+-------------+ +-------------+ +-------------+ +-------------+
Where following values are Valid:
|--------------------------------------------------------------------------------------------------------------------------|
| Binary Hex Name Address ValueL ValueH Reply Description|
|--------------------------------------------------------------------------------------------------------------------------|
| 0000001 0x01 Read-Temp Number of zeroes/Rand zeroes/Rand A 16Bit Value Reads the |
| Thermometer Representing Temperature|
| Starting with 0 the Temperature |
|--------------------------------------------------------------------------------------------------------------------------|
| 0000002 0x02 Read-Var8 Number of the zeroes/Rand zeroes/Rand A 8Bit Value Reads 8Bit |
| var-DEFINE read from VAR Variable |
|--------------------------------------------------------------------------------------------------------------------------|
| 0000003 0x03 Read-Var16 Number of the zeroes/Rand zeroes/Rand A 16Bit Value Reads 16Bit|
| var-DEFINE read from VAR Variable |
|--------------------------------------------------------------------------------------------------------------------------|
| 0000004 0x04 Write-Var8 Number of the Value of Var zeroes/Rand zeroes/Rand Writes 8Bit|
| var-DEFINE to write Variable |
|--------------------------------------------------------------------------------------------------------------------------|
| 0000005 0x05 Write-Var16 Number of the Value of Var Value of Var zeroes/Rand Writes 16 |
| var-DEFINE to write (HIGH) to write (LOW) Bit Var |
|--------------------------------------------------------------------------------------------------------------------------|

@ -1,6 +1,6 @@
DEFINES += -DF_CPU=16000000
CFLAGS += -save-temps
CFLAGS += -std=gnu99 # implements C99, for <util/atomic.h>
CFLAGS += -std=gnu99 -Wall # implements C99, for <util/atomic.h>
# this removes dead code and does global linker optimization
#CFLAGS += -ffunction-sections -Wl,--gc-sections -Wl,--relax

@ -255,10 +255,6 @@ void display_bar(int8_t value, int8_t min, int8_t max) {
}
}
void updateTemperature() {
if(newThermoData==1) {
newThermoData = 0;

@ -5,11 +5,16 @@
#include "lcd/lcd.h"
#include "main.h"
#define LCD_CHAR_HALFBAR 0x01
#define LCD_CHAR_BAR 0x02
#define LCD_CHAR_DEGREE 0x03
#define LCD_CHAR_BLANK 0x20
extern uint8_t newThermoData1;
extern uint16_t thermoData[];
extern const prog_uint8_t lcd_halfbar_char[];
extern const prog_uint8_t lcd_bar_char[];
extern const prog_uint8_t lcd_degree_char[];
@ -33,6 +38,6 @@ extern void display_puthex(uint8_t outbyte);
extern void display_bar(int8_t value, int8_t min, int8_t max);
extern void display_putint(int16_t number);
void updateTemperature();
extern void updateTemperature();
#endif

@ -1,10 +1,13 @@
#include "main.h"
#define SOFTTIMERNUMS 4
uint8_t newThermoData = 1;
uint16_t thermoData[] = {1024, 814, 2475, 2243};
volatile uint16_t timer1_acc;
uint16_t softtimer_last[SOFTTIMERNUMS];
void softtimer_reset(uint8_t timernum){
softtimer_last[SOFTTIMERNUMS] = timer1_acc;
softtimer_last[timernum] = timer1_acc;
}
uint8_t softtimer(uint8_t timernum, uint16_t interval){
@ -16,7 +19,8 @@ uint8_t softtimer(uint8_t timernum, uint16_t interval){
return(0);
}
#define SOFTTIMER(n,a) if(softtimer((n),(a*4)))
// SOFTTIMER( <YOUR TIMER NUM>, <YOUR INTERVAL>);
#define SOFTTIMER(n,a) if(softtimer((n),(a*8)))
void hardinit() {
@ -35,6 +39,9 @@ void hardinit() {
OCR1A = 15; // contrast
OCR1B = 50; // brightness
// enable softtimer isr
TIMSK1 |= _BV(TOIE1);
// init LCD:
lcd_init(1);
@ -51,27 +58,25 @@ void softinit() {
int __attribute__((noreturn)) main(void) {
int i=0;
hardinit();
softinit();
usbInit();
display_puts("Hallo, Welt!\n\n");
display_update();
for(;;){
usbPoll();
SOFTTIMER(1,100){
updateTemperature();
SOFTTIMER(2,500) {
thermoData[0]=thermoData[0]+5;
thermoData[1]=thermoData[1]+15;
thermoData[2]=thermoData[2]+7;
thermoData[3]=thermoData[3]+18;
newThermoData = 1;
}
SOFTTIMER(1,250) {
updateTemperature();
}
thermoData[0]=thermoData[0]+5;
thermoData[1]=thermoData[1]+15;
thermoData[2]=thermoData[2]+7;
thermoData[3]=thermoData[3]+18;
i++; if(i%200 == 0) newThermoData = 1;
}
}
@ -82,16 +87,18 @@ int __attribute__((noreturn)) main(void) {
asm volatile ("out %1, %0\n" : "=r" (sreg_store) : "I" (_SFR_IO_ADDR(SREG)));
reti();
}*/
ISR(TIMER1_OVF_vect,ISR_NOBLOCK){
uint16_t temp;
temp=timer1_acc;
temp++;
ATOMIC_BLOCK(ATOMIC_FORCEON){
timer1_acc=temp;
}
uint16_t tmp;
tmp=timer1_acc;
tmp++;
/* 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.
*/
}
ATOMIC_BLOCK(ATOMIC_FORCEON){
timer1_acc=tmp;
}
}

@ -26,11 +26,10 @@
#include "spi.h"
#include "usb.h"
extern uint8_t newThermoData;
extern uint16_t thermoData[];
static uint8_t newThermoData = 1;
static uint16_t thermoData[] = {1024, 814, 2475, 2243};
volatile uint16_t timer1_acc;
#define SOFTTIMERNUMS 4
#define LED1PORT PORTC
#define LED1APIN 0

Loading…
Cancel
Save