Changeset 6390cc3 in avrstuff
- Timestamp:
- Sep 24, 2017, 7:39:05 PM (7 years ago)
- Branches:
- main
- Children:
- 6c47e45
- Parents:
- 9a9d5d0
- git-author:
- Adrien Destugues <pulkomandy@…> (24/09/2017 17:13:58)
- git-committer:
- Adrien Destugues <pulkomandy@…> (24/09/2017 19:39:05)
- Files:
-
- 1 deleted
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
chiptest/Makefile
r9a9d5d0 r6390cc3 1 # STK500 2 F_CPU=3800000 3 MCU=atmega128 4 1 5 # K4KUSB 2 F_CPU=12000000 6 #F_CPU=12000000 7 #MCU=attiny2313 3 8 4 9 # muSerial 5 10 # F_CPU=20000000 11 #MCU=attiny2313 6 12 7 13 # Common 8 MCU=attiny23139 14 BAUD=9600 10 15 … … 13 18 include ../kbd/common.mk 14 19 15 COMPILE = $(CC) -Wall -Os -std=c99 -mmcu=$(MCU) -DF_CPU=$(F_CPU) -DBAUD=$(BAUD) \ 16 -I../libs/usart/ 20 COMPILE = $(CC) -Wall -std=c99 $(CFLAGS) -I../libs/usart/ 17 21 18 22 VPATH=../libs/usart/ … … 20 24 #Rules 21 25 22 blinkdel.bin: main.o usart.o26 $(MCU).bin: main.o usart.o 23 27 $(COMPILE) $^ -o $@ 24 28 … … 33 37 $(COMPILE) -std=c99 -c $< -o $@ 34 38 35 flash:36 avrdude -c usbasp -p $(MCU) -Uflash:w:blinkdel.hex37 -
chiptest/main.c
r9a9d5d0 r6390cc3 12 12 // muSerial: ATTiny2313 - LED = PD6 13 13 // K4KUSB: ATTiny2313 - LED = PB2 14 #define DDRLED DDRB 15 #define PORTLED PORTB 16 #define LEDBIT (1 << PB2) 17 18 #define BAUD 9600 // Safe value even for low clocks. (used by setbaud.h) 14 // STK500: anything, PORTD is convenient if available. 15 #define DDRLED DDRC 16 #define PORTLED PORTC 17 #define LEDBIT (1 << PC2) 19 18 20 19 int main() { 21 20 wdt_enable(WDTO_2S); 22 21 // configure timer 0 for a rate of FCPU/(256 * 256) 22 #ifdef __AVR_ATtiny2313__ 23 23 TCCR0A = 0; // timer 0 prescaler: 256 24 24 TCCR0B = 4; 25 #else 26 TCCR0 = 6; // timer 0 prescaler: 256 27 #endif 25 28 26 29 //debug LED - output … … 32 35 // Let's rock! 33 36 uint8_t counter = 0; 37 char c = 'a'; 34 38 for(;;) { 35 39 wdt_reset(); … … 43 47 { 44 48 PORTLED ^= LEDBIT; // Toggle the LED 45 USARTWriteChar('H'); // Send a byte to the UART 49 USARTWriteChar(c++); // Send a byte to the UART 50 if (c > 'z') 51 c = 'a'; 46 52 } 47 53 } -
chiptest/readme.md
r9a9d5d0 r6390cc3 11 11 Right now chiptest supports the following devices: 12 12 * ATTiny2313. 13 * ATmega128 13 14 14 15 It tests the following features: -
kbd/common.mk
r9a9d5d0 r6390cc3 20 20 21 21 flash: $(MCU).hex 22 $(AVRDUDE) -c usbasp-p $(MCU) -Uflash:w:$^22 $(AVRDUDE) -c stk500 -P /dev/ports/usb0 -p $(MCU) -Uflash:w:$^ 23 23 24 24 clean: -
libs/usart/usart.c
r9a9d5d0 r6390cc3 6 6 #ifndef BAUD 7 7 #error You must define BAUD to use libuart. 8 #endif 9 10 #ifdef __AVR_ATmega128__ 11 // FIXME there are two USARTs in this case and we should be able to drive either 12 #define UBRRH UBRR0H 13 #define UBRRL UBRR0L 14 #define UCSRA UCSR0A 15 #define UCSRC UCSR0C 16 #define UCSRB UCSR0B 17 #define UDR UDR0 8 18 #endif 9 19 … … 29 39 #ifdef __AVR_ATtiny2313__ 30 40 UCSRC = (1 << UCSZ1) | (1 << UCSZ0); 41 #elif defined __AVR_ATmega128__ 42 UCSRC = (3 << UCSZ0); 31 43 #else 32 44 UCSRC = (1 << URSEL) | (3 << UCSZ0);
Note:
See TracChangeset
for help on using the changeset viewer.