add LED macros, bump version

This commit is contained in:
Olaf Rempel 2011-02-20 14:40:42 +01:00
parent d281696895
commit 9424e20ea7
1 changed files with 18 additions and 13 deletions

31
main.c
View File

@ -38,15 +38,15 @@
*/
#if defined (__AVR_ATmega8__)
#define VERSION_STRING "TWIBOOT m8v2.0"
#define VERSION_STRING "TWIBOOT m8v2.1"
#define SIGNATURE_BYTES 0x1E, 0x93, 0x07
#elif defined (__AVR_ATmega88__)
#define VERSION_STRING "TWIBOOT m88v2.0"
#define VERSION_STRING "TWIBOOT m88v2.1"
#define SIGNATURE_BYTES 0x1E, 0x93, 0x0A
#elif defined (__AVR_ATmega168__)
#define VERSION_STRING "TWIBOOT m168v2.0"
#define VERSION_STRING "TWIBOOT m168v2.1"
#define SIGNATURE_BYTES 0x1E, 0x94, 0x06
#else
@ -61,10 +61,15 @@
/* 40 * 25ms */
#define TIMEOUT 40
#define LED_RT (1<<PORTB4)
#define LED_GN (1<<PORTB5)
#define LED_INIT() DDRB = ((1<<PORTB4) | (1<<PORTB5))
#define LED_RT_ON() PORTB |= (1<<PORTB4)
#define LED_RT_OFF() PORTB &= ~(1<<PORTB4)
#define LED_GN_ON() PORTB |= (1<<PORTB5)
#define LED_GN_OFF() PORTB &= ~(1<<PORTB5)
#define LED_GN_TOGGLE() PORTB ^= (1<<PORTB5)
#define LED_OFF() PORTB = 0x00
#define TWI_ADDRESS 0x21
#define TWI_ADDRESS 0x29
/* SLA+R */
#define CMD_WAIT 0x00
@ -214,7 +219,7 @@ ISR(TWI_vect)
/* SLA+W received, ACK returned -> receive data and ACK */
case 0x60:
bcnt = 0;
PORTB |= LED_RT;
LED_RT_ON();
TWCR |= (1<<TWINT) | (1<<TWEA);
break;
@ -314,7 +319,7 @@ ISR(TWI_vect)
/* SLA+R received, ACK returned -> send data */
case 0xA8:
bcnt = 0;
PORTB |= LED_RT;
LED_RT_ON();
/* prev. SLA+R, data sent, ACK returned -> send data */
case 0xB8:
@ -350,7 +355,7 @@ ISR(TWI_vect)
case 0xA0:
/* data sent, NACK returned */
case 0xC0:
PORTB &= ~LED_RT;
LED_RT_OFF();
TWCR |= (1<<TWINT) | (1<<TWEA);
break;
@ -367,7 +372,7 @@ ISR(TIMER0_OVF_vect)
TCNT0 = TIMER_RELOAD;
/* blink LED while running */
PORTB ^= LED_GN;
LED_GN_TOGGLE();
/* count down for app-boot */
if (boot_timeout > 1)
@ -398,8 +403,8 @@ void disable_wdt_timer(void)
int main(void) __attribute__ ((noreturn));
int main(void)
{
DDRB = LED_GN | LED_RT;
PORTB = LED_GN;
LED_INIT();
LED_GN_ON();
/* move interrupt-vectors to bootloader */
/* timer0: running with F_CPU/1024, OVF interrupt */
@ -444,7 +449,7 @@ int main(void)
MCUCR = (0<<IVSEL);
#endif
PORTB = 0x00;
LED_OFF();
uint16_t wait = 0x0000;
do {