Basic Arduino skeleton
This commit is contained in:
parent
b0eab39a46
commit
b58818bb08
30
Makefile
30
Makefile
|
@ -1,7 +1,27 @@
|
||||||
CC = msp430-gcc
|
CC = avr-gcc
|
||||||
CFLAGS += -mmcu=msp430g2553
|
CFLAGS += -mmcu=atmega328p
|
||||||
CFLAGS += -Wall
|
CFLAGS += -DF_CPU=16000000UL
|
||||||
CFLAGS += -Os
|
CFLAGS += -Os
|
||||||
CFLAGS += -g
|
CFLAGS += -w
|
||||||
|
|
||||||
|
AVDFLAGS += -p m328p
|
||||||
|
AVDFLAGS += -c arduino
|
||||||
|
AVDFLAGS += -b 115200
|
||||||
|
AVDFLAGS += -P /dev/ttyACM0
|
||||||
|
|
||||||
|
|
||||||
|
upload: .upload
|
||||||
|
|
||||||
|
.upload: blink.hex
|
||||||
|
avrdude $(AVDFLAGS) -U flash:w:$<
|
||||||
|
touch $@
|
||||||
|
|
||||||
|
blink.hex: blink
|
||||||
|
avr-objcopy -O ihex -R .eeprom -R .fuse -R .lock -R .signature $< $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f blink.hex blink
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
all: main blink
|
|
||||||
|
|
47
blink.c
47
blink.c
|
@ -1,28 +1,39 @@
|
||||||
#include <msp430.h>
|
#include <avr/io.h>
|
||||||
|
#include <util/delay.h>
|
||||||
|
|
||||||
unsigned int i = 0;
|
|
||||||
|
|
||||||
unsigned char bits1 = BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7;
|
int main (void)
|
||||||
unsigned char bits2 = BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5;
|
|
||||||
|
|
||||||
int
|
|
||||||
main(void)
|
|
||||||
{
|
{
|
||||||
WDTCTL = WDTPW + WDTHOLD;
|
unsigned char counter;
|
||||||
P1DIR |= bits1;
|
/* set PORTB for output*/
|
||||||
P2DIR |= bits2;
|
DDRB = 0xFF;
|
||||||
|
|
||||||
P1OUT |= bits1;
|
while (1)
|
||||||
P2OUT &= ~bits2;
|
{
|
||||||
|
/* set PORTB.2 high */
|
||||||
|
PORTB = 0xFF;
|
||||||
|
|
||||||
for (;;) {
|
/* wait (10 * 120000) cycles = wait 1200000 cycles */
|
||||||
i = (i + 1) % 40000;
|
counter = 0;
|
||||||
|
while (counter != 50)
|
||||||
|
{
|
||||||
|
/* wait (30000 x 4) cycles = wait 120000 cycles */
|
||||||
|
_delay_loop_2(60000);
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
|
||||||
if (i == 0) {
|
/* set PORTB.2 low */
|
||||||
P1OUT ^= bits1;
|
PORTB = 0x00;
|
||||||
P2OUT ^= bits2;
|
|
||||||
|
/* wait (10 * 120000) cycles = wait 1200000 cycles */
|
||||||
|
counter = 0;
|
||||||
|
while (counter != 50)
|
||||||
|
{
|
||||||
|
/* wait (30000 x 4) cycles = wait 120000 cycles */
|
||||||
|
_delay_loop_2(30000);
|
||||||
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
Loading…
Reference in New Issue