Basic Arduino skeleton
This commit is contained in:
parent
b0eab39a46
commit
b58818bb08
30
Makefile
30
Makefile
|
@ -1,7 +1,27 @@
|
|||
CC = msp430-gcc
|
||||
CFLAGS += -mmcu=msp430g2553
|
||||
CFLAGS += -Wall
|
||||
CC = avr-gcc
|
||||
CFLAGS += -mmcu=atmega328p
|
||||
CFLAGS += -DF_CPU=16000000UL
|
||||
CFLAGS += -Os
|
||||
CFLAGS += -g
|
||||
CFLAGS += -w
|
||||
|
||||
all: main blink
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
63
blink.c
63
blink.c
|
@ -1,28 +1,39 @@
|
|||
#include <msp430.h>
|
||||
|
||||
unsigned int i = 0;
|
||||
|
||||
unsigned char bits1 = BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7;
|
||||
unsigned char bits2 = BIT0 + BIT1 + BIT2 + BIT3 + BIT4 + BIT5;
|
||||
|
||||
int
|
||||
main(void)
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
WDTCTL = WDTPW + WDTHOLD;
|
||||
P1DIR |= bits1;
|
||||
P2DIR |= bits2;
|
||||
|
||||
P1OUT |= bits1;
|
||||
P2OUT &= ~bits2;
|
||||
|
||||
for (;;) {
|
||||
i = (i + 1) % 40000;
|
||||
|
||||
if (i == 0) {
|
||||
P1OUT ^= bits1;
|
||||
P2OUT ^= bits2;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
unsigned char counter;
|
||||
/* set PORTB for output*/
|
||||
DDRB = 0xFF;
|
||||
|
||||
while (1)
|
||||
{
|
||||
/* set PORTB.2 high */
|
||||
PORTB = 0xFF;
|
||||
|
||||
/* wait (10 * 120000) cycles = wait 1200000 cycles */
|
||||
counter = 0;
|
||||
while (counter != 50)
|
||||
{
|
||||
/* wait (30000 x 4) cycles = wait 120000 cycles */
|
||||
_delay_loop_2(60000);
|
||||
counter++;
|
||||
}
|
||||
|
||||
/* set PORTB.2 low */
|
||||
PORTB = 0x00;
|
||||
|
||||
/* 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 1;
|
||||
}
|
Loading…
Reference in New Issue