"/usr/lib/gcc/avr/**"
],
"defines": [],
- "compilerPath": "/usr/bin/avr-gcc",
- "compilerArgs": [ "-mmcu=atmega644p", "-DF_CPU=12000000", "-Os" ],
+ "compilerPath": "/usr/bin/avr-g++",
+ "compilerArgs": [ "-mmcu=atmega1284p", "-DF_CPU=12000000", "-Os" ],
"cStandard": "gnu11",
"cppStandard": "gnu++11",
"intelliSenseMode": "linux-gcc-x64"
CC= avr-g++
CFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -DBAUD_RATE=$(BAUDRATE) -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c
-#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,-u,vfprintf -lprintf_flt -lm
-LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS)
+LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS) -Wl,-u,vfprintf -lprintf_flt -lm
+#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS)
CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -DBAUD_RATE=$(BAUDRATE) -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c
-#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,-u,vfprintf -lprintf_flt -lm
-LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS)
+LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS) -Wl,-u,vfprintf -lprintf_flt -lm
+#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS)
# --------------------------------------------------------------------------------
# make targets
CC= avr-g++
CFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -DBAUD_RATE=$(BAUDRATE) -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c
-#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,-u,vfprintf -lprintf_flt -lm
-LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS)
+LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS) -Wl,-u,vfprintf -lprintf_flt -lm
+#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS)
CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -DBAUD_RATE=$(BAUDRATE) -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c
-#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,-u,vfprintf -lprintf_flt -lm
-LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS)
+LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS) -Wl,-u,vfprintf -lprintf_flt -lm
+#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS)
# --------------------------------------------------------------------------------
# make targets
CC= avr-g++
CFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -DBAUD_RATE=$(BAUDRATE) -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c
-#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,-u,vfprintf -lprintf_flt -lm
-LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS)
+LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS) -Wl,-u,vfprintf -lprintf_flt -lm
+#LFLAGS= -Wall -mmcu=$(DEVICE) -Os -DF_CPU=$(CPU_FREQUENCY) -Wl,--section-start=.text=$(START_ADDRESS)
CFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -DBAUD_RATE=$(BAUDRATE) -DDOUBLE_SPEED -DNUM_LED_FLASHES=4 '-DMAX_TIME_COUNT=F_CPU>>4' -c
-#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,-u,vfprintf -lprintf_flt -lm
-LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS)
+LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS) -Wl,-u,vfprintf -lprintf_flt -lm
+#LFLAGS_SIM= -Wall -mmcu=$(DEVICE) -Og -DF_CPU=$(CPU_FREQUENCY) -g -Wl,--section-start=.text=$(START_ADDRESS)
# --------------------------------------------------------------------------------
# make targets
if (hardwareVersion < 1 || hardwareVersion > 2) {
#ifdef __AVR_ATmega644P__
- printf_P(PSTR("\nInvalid Hardware-Version: ADC7H = %d (ATmega644P, 3.3V)\n"), ADCH);
+ printf_P(PSTR("\nInvalid Nano-X-Base Hardware-Version: ADC7H = %d (ATmega644P, 3.3V)\n"), ADCH);
#elif __AVR_ATmega1284P__
- printf_P(PSTR("\nInvalid Hardware-Version: ADC7H = %d (ATmega1284P, 3.3V)\n"), ADCH);
+ printf_P(PSTR("\nInvalid Nano-X-Base Hardware-Version: ADC7H = %d (ATmega1284P, 3.3V)\n"), ADCH);
#elif __AVR_ATmega328P__
- printf_P(PSTR("\nInvalid Hardware-Version: ADC7H = %d (ATmega328P, 5V)\n"), ADCH);
+ printf_P(PSTR("\nInvalid Nano-X-Base Hardware-Version: ADC7H = %d (ATmega328P, 5V)\n"), ADCH);
#endif
+ hardwareVersion = 0;
} else {
// const char *pHw; memcpy_P(&pHw, PSTR_HARDWARE + hardwareVersion - 1, sizeof(const char *));
printf_P(PSTR("\n\nHardware %S detected (ADC7H=0x%02X)"), hardwareVersionPStr(hardwareVersion), ADCH);
sei();
+ detectHardwareVersion();
+
+ uint8_t units;
#if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__)
TestUnit *unit[] = {
- &led, &sw, &rgb, &seg7, &poti, &encoder, &r2r, &motor, &portExp, &lcd, &uart1, &modbus, &ieee485,
- &i2cMaster, &i2cSlave, &i2cSparkfun, &rtc8563, &cc1101Send, &cc1101Receive
+ &uart1, &i2cMaster, &i2cSlave, &i2cSparkfun, &rtc8563, &cc1101Send, &cc1101Receive,
+ &led, &sw, &rgb, &seg7, &poti, &encoder, &r2r, &motor, &portExp, &lcd, &modbus, &ieee485
};
+ units = hardwareVersion == 0 ? 7 : sizeof(unit) / sizeof(unit[0]);
#endif
#ifdef __AVR_ATmega328P__
TestUnit *unit[] = {
- &led, &sw, &rgb, &seg7, &poti, &encoder, &r2r, &motor, &portExp, &lcd,
- &i2cMaster, &i2cSlave, &i2cSparkfun
+ &i2cMaster, &i2cSlave, &i2cSparkfun,
+ &led, &sw, &rgb, &seg7, &poti, &encoder, &r2r, &motor, &portExp, &lcd
};
+ units = hardwareVersion == 0 ? 3 : sizeof(unit) / sizeof(unit[0]);
#endif
- detectHardwareVersion();
+
while (1) {
uint16_t i;
printf_P(MAIN_CPP_TIME);
printf_P(PSTR_DIVIDER);
if (hardwareVersion >= 1 && hardwareVersion <= 2) {
- printf_P(PSTR("Hardware: %S"), hardwareVersionPStr(hardwareVersion));
+ printf_P(PSTR("Nano-X-Base: %S"), hardwareVersionPStr(hardwareVersion));
} else {
- printf_P(PSTR("ERROR: Invalid Hardware (%d)"), hardwareVersion);
- for(;;);
+ printf_P(PSTR("No Nano-X-Base detected"));
}
printf_P(PSTR_DIVIDER);
printf_P(PSTR_LINEFEED);
printf_P(PSTR("Available units:\n\n"));
- for (i = 0; i < sizeof(unit) / sizeof(unit[0]); i++) {
+ for (i = 0; i < units; i++) {
TestUnit *pu = unit[i];
printf_P(PSTR("%3x ... "), i);
printf_P(pu->getName());
printf_P(PSTR("\nSelect unit: "));
rIndex = 0; wIndex = 0;
fgets(s, sizeof(s), stdin);
- } while (sscanf(s, "%x", &i) != 1 || i < 0 || i >= sizeof(unit) / sizeof(unit[0]) );
+ } while (sscanf(s, "%x", &i) != 1 || i < 0 || i >= units );
TestUnit *pu = unit[i];
printf_P(PSTR("\n\n[")); printf_P(pu->getName()); printf_P(PSTR("]: "));
int8_t Cc1101::run (uint8_t subtest) {
+ if (!initDone) {
+ return -1;
+ }
switch (mode) {
case Send: return runSend(subtest);
case Receive: return runReceive(subtest);
void Cc1101::init () {
+ // trigger for debugging
+ PORTB &= ~(1 << PB0);
+ DDRB |= ( 1 << PB0);
+
#ifdef __AVR_ATmega1284P__
// Nano-1284
+ triggerOn();
DDRC |= (1 << PC6);
PORTC |= (1 << PC6); // modem voltage 3.3V ON
+ _delay_us(100);
+ triggerOff();
#endif
- // trigger for debugging
- PORTB &= ~(1 << PB0);
- DDRB |= ( 1 << PB0);
-
PRR0 &= (1 << PRSPI);
// nCs
return;
}
printf_P(PSTR("OK"));
+ initDone = true;
debugPrint.byte = 0xff; // print all
printRegisters();
DDRC &= ~(1 << PC6);
PORTC &= ~(1 << PC6); // modem voltage 3.3V OFF
#endif
+
+ initDone = false;
}
void Cc1101::setChipEnableLow () {
+ triggerOn();
PORTA &= ~(1 << PA4);
+ // _delay_us(20); // measurement shows -> delay not needed
}
void Cc1101::setChipEnableHigh () {
+ triggerOff();
+ _delay_us(40); // measurement shows -> delay needed before(!) signal rises high
PORTA |= (1 << PA4);
}
ok &= waitForMisoLow();
ok &= strobe(SRES);
ok &= waitForMisoLow();
-
-
return ok;
}
} status;
public:
- Cc1101 (Cc1101Mode mode) { timer = 0; this->mode = mode; status.dword = 0; }
+ Cc1101 (Cc1101Mode mode) { timer = 0; this->mode = mode; status.dword = 0; initDone = false; }
virtual void init ();
virtual void cleanup ();
virtual int8_t run (uint8_t subtest);
private:
+ bool initDone;
Cc1101Mode mode;
- uint8_t timer;
+ volatile uint8_t timer;
union {
DebugPrint_t print;
uint8_t byte;