Compare commits

...

4 commits

Author SHA1 Message Date
stephan
4e5d4fa092 avr/chaos: fix SPI ports
git-svn-id: svn+ssh://asterix.ieap.uni-kiel.de/home/subversion/stephan/solo/eda/arm/avr@8981 bc5caf13-1734-44f8-af43-603852e9ee25
2024-06-03 18:33:17 +00:00
stephan
e1cdb1b2f5 avr/chaos: fix LED ports
git-svn-id: svn+ssh://asterix.ieap.uni-kiel.de/home/subversion/stephan/solo/eda/arm/avr@8980 bc5caf13-1734-44f8-af43-603852e9ee25
2024-06-03 18:32:57 +00:00
stephan
049f835ce8 arm/avr: fix hv_safe() w/ timeout in case the ADS is missing
git-svn-id: svn+ssh://asterix.ieap.uni-kiel.de/home/subversion/stephan/solo/eda/arm/avr@8978 bc5caf13-1734-44f8-af43-603852e9ee25
2024-05-31 17:20:20 +00:00
stephan
477e1a1f6d arm/avr: make %.ad
git-svn-id: svn+ssh://asterix.ieap.uni-kiel.de/home/subversion/stephan/solo/eda/arm/avr@8975 bc5caf13-1734-44f8-af43-603852e9ee25
2024-05-31 17:00:14 +00:00
5 changed files with 18 additions and 10 deletions

View file

@ -85,3 +85,7 @@ lcd.o: lcd.c spi_slave.h lcd_routines.h lcd_routines.c uart_atmega16.c
$(AD) -U eeprom:r:$@
%.eeprom.burn: %.eeprom
$(AD) -U eeprom:v:$< || $(AD) -U eeprom:w:$<
%.ad:
$(AD) -v -t

View file

@ -1,8 +1,9 @@
#include "avr/io.h"
#define ADC_SDI 4
#define ADC_SDI 7
#define ADC_SCK 5
#define ADC_CE 7
#define ADC_CE 4
#define ADC_SDO 1
#define ADC_RST 0
#define ADC_PO PORTD
#define ADC_PI PORTD
#define ADC_PO_IO _SFR_IO_ADDR(ADC_PO)

View file

@ -252,8 +252,8 @@ unsigned int adc_hv;
int hv_is_safe()
{
return !hvosc_is_on()
&& conf.dac == conf.dac_off
&& adc_hv < conf.hvadc_safe
&& conf.dac <= conf.dac_off
&& adc_hv <= conf.hvadc_safe
;
}
@ -277,9 +277,12 @@ void hv_safe()
unsigned char sreg = disable_irq();
ltc1655_cmd(INT2FRAME(conf.dac_off));
conf.dac = conf.dac_off;
while (!read_hvadc())
if (adc_hv < conf.hvadc_safe)
unsigned int adc_last = 0xffff;
while (!read_hvadc()) {
if (adc_hv < conf.hvadc_safe || adc_hv >= adc_last)
break;
adc_last = adc_hv;
}
enable_irq(sreg);
toggle_hv_led();
}
@ -295,7 +298,7 @@ int main()
ltc1655_init();
hv_safe();
eeprom_load(0);
if (conf.magic == MAGIC || conf.version == VERSION)
if (conf.magic == MAGIC && conf.version == VERSION)
conf_init();
while (1) {
unsigned char cmd[3];

View file

@ -1,7 +1,7 @@
#include "avr/io.h"
#define LED1 2
#define LED1 4
#define LED2 3
#define LED_PORT PORTC
#define LED_PORT PORTB
#define LED_GREEN (1<<LED1)
#define LED_RED (1<<LED2)
#define LED_MASK (LED_GREEN | LED_RED)

View file

@ -1,5 +1,5 @@
#include "avr/io.h"
#define DAC_SDI 4
#define DAC_SDI 7
#define DAC_SCK 5
#define DAC_CE 6
#define DAC_PORT PORTD