#BSL := avrdude -V -F -c stk500v1 -p m328p -b 57600 -P /dev/ttyACM0 -U flash:w:goodfet.hex
CFLAGS=$(DEBUG) -Iinclude -mmcu=$(mcu) -W -Os -mcall-prologues -Wall -Wextra -Wuninitialized -fpack-struct -fshort-enums -funsigned-bitfields
LDFLAGS :=
-config := monitor
+config := monitor nrf
AVR_PLATFORM := m328p
endif
# define SS (1 << PA3)
# define TST (1 << PA4)
# define XRST (1 << PA5)
+#elif (platform == arduino)
+// pin Arduini - nrf pin
+// - nrf 1 GND
+// - nrf 2 +3.3V
+# define CE (1 << PB0) // pin 8 - nrf 3 CE
+# define CS (1 << PB1) // pin 9 - nrf 4 CSN
+//# define CS (1 << PB2) // pin 10 CS
+# define MOSI (1 << PB3) // pin 11 MOSI - nrf 6 MOSI
+# define MISO (1 << PB4) // pin 12 MISO - nrf 7 MISO
+# define SCK (1 << PB5) // pin 13 SCL - nrf 5 CLK
+// - nrf 8 IRQ
+//# define TST (1 << PA4)
+//# define XRST (1 << PA5)
#else
# define MOSI BIT1
# define MISO BIT2
# define CLRTST PORTA&=~(1 << PA4);
# define SETRST PORTA|=(1 << PA5);
# define CLRRST PORTA&=~(1 << PA5);
+#elif (platform == arduino)
+//# define SETTST PORTA|=(1 << PA4);
+//# define CLRTST PORTA&=~(1 << PA4);
+//# define SETRST PORTA|=(1 << PA5);
+//# define CLRRST PORTA&=~(1 << PA5);
#else
# define SETTST P4OUT|=TST
# define CLRTST P4OUT&=~TST
#define PLEDDIR DDRB
#define PLEDPIN PB5
-//Use P3 instead of P5 for target I/O on chips without P5.
-#define SPIOUT P5OUT
-#define SPIDIR P5DIR
-#define SPIIN P5IN
-#define SPIREN P5REN
-
-//No longer works for Hope badge.
-#define SETSS P5OUT|=BIT0
-#define CLRSS P5OUT&=~BIT0
-#define DIRSS P5DIR|=BIT0;
-
-//Used for the Nordic port, !RST pin on regular GoodFET.
-#define SETCE P2OUT|=BIT6
-#define CLRCE P2OUT&=~BIT6
-#define DIRCE P2DIR|=BIT6
+#define SPIOUT PORTB
+#define SPIDIR DDRB
+#define SPIIN PINB
+
+// see also include/spi.h
+#define SETSS PORTB|=SS;
+#define CLRSS PORTB&=~SS;
+#define DIRSS DDRB|=SS;
+
+#define SETCE PORTB|=CE
+#define CLRCE PORTB&=~CE
+#define DIRCE PORTB|=CE
// network byte order converters
#define htons(x) ((((uint16_t)(x) & 0xFF00) >> 8) | \