From: gitknilch Date: Sun, 20 Feb 2011 11:57:48 +0000 (+0100) Subject: remove master mode, disable uart tx X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/fnordlicht-mini/commitdiff_plain/e06282dce0420369b589ec793c567a8a2cc48603?ds=sidebyside remove master mode, disable uart tx --- diff --git a/firmware/fnordlicht-firmware/Makefile b/firmware/fnordlicht-firmware/Makefile index 0fffc69..c18e3ba 100644 --- a/firmware/fnordlicht-firmware/Makefile +++ b/firmware/fnordlicht-firmware/Makefile @@ -56,8 +56,6 @@ CONFIG_REMOTE = 1 CONFIG_SECONDARY_PWM = 1 # default baudrate CONFIG_SERIAL_BAUDRATE = 19200 -# check jumper for master mode -CONFIG_MASTER_MODE = 1 # avrdude programmer protocol PROG = usbasp @@ -70,7 +68,6 @@ CFLAGS += -DHARDWARE_$(HARDWARE)=1 -DCONFIG_SCRIPT_DEFAULT=$(CONFIG_SCRIPT_DEFAU CFLAGS += -DCONFIG_SCRIPT=$(CONFIG_SCRIPT) -DCONFIG_SERIAL=$(CONFIG_SERIAL) CFLAGS += -DCONFIG_REMOTE=$(CONFIG_REMOTE) -DCONFIG_SECONDARY_PWM=$(CONFIG_SECONDARY_PWM) CFLAGS += -DCONFIG_SERIAL_BAUDRATE=$(CONFIG_SERIAL_BAUDRATE) -CFLAGS += -DCONFIG_MASTER_MODE=$(CONFIG_MASTER_MODE) #################################################### # 'make' configuration diff --git a/firmware/fnordlicht-firmware/config.h b/firmware/fnordlicht-firmware/config.h index b708a48..3ac7d9a 100644 --- a/firmware/fnordlicht-firmware/config.h +++ b/firmware/fnordlicht-firmware/config.h @@ -67,15 +67,6 @@ #define CONFIG_SERIAL_BAUDRATE 19200 #endif -/* configure master mode: - * 0 disable master mode completely - * 1 check if master mode jumper is set (default) - * 2 always act as master - */ -#ifndef CONFIG_MASTER_MODE -#define CONFIG_MASTER_MODE 1 -#endif - /* check if hardware is valid */ #if defined(HARDWARE_fnordlicht) /* specific settings for old fnordlicht hardware */ diff --git a/firmware/fnordlicht-firmware/remote.c b/firmware/fnordlicht-firmware/remote.c index d6f54f7..fcaf672 100644 --- a/firmware/fnordlicht-firmware/remote.c +++ b/firmware/fnordlicht-firmware/remote.c @@ -63,9 +63,6 @@ struct remote_state_t uint8_t sync; uint8_t synced; struct pt thread; -#if CONFIG_MASTER_MODE - struct pt master_thread; -#endif /* int line */ timer_t int_timer; @@ -115,17 +112,6 @@ void remote_init(void) R_PORT &= ~_BV(INTPIN); #ifdef INIT_ZERO remote.int_state = INT_IDLE; - - PT_INIT(&remote.master_thread); -#endif - -#if CONFIG_MASTER_MODE == 1 - /* check master state: read value of M_PIN1 */ - if (!(M_PIN & _BV(M_PIN1))) - global_remote.master = true; -#elif CONFIG_MASTER_MODE == 2 - /* statically configure master mode */ - global_remote.master = true; #endif } @@ -209,90 +195,6 @@ static void send_resync(uint8_t addr) uart_putc(addr); } -#if CONFIG_MASTER_MODE -/* parameters for master mode script commands */ -#define MASTER_PROGRAMS 2 -static PROGMEM uint8_t master_parameters[] = { - /* first: colorwheel forward */ - 0, /* program index */ - 1, /* fade step */ - 2, /* fade delay */ - 0, /* fade sleep */ - 0, 0, /* hue start (little endian) */ - 20, 0, /* hue step (little endian) */ - -1, /* addr add */ - 255, /* saturation */ - 255, /* value */ - - /* first: colorwheel backward */ - 0, /* program index */ - 1, /* fade step */ - 2, /* fade delay */ - 0, /* fade sleep */ - 0, 0, /* hue start (little endian) */ - 20, 0, /* hue step (little endian) */ - 1, /* addr add */ - 255, /* saturation */ - 255, /* value */ -}; - -static PT_THREAD(remote_master_thread(struct pt *thread)) -{ - static struct remote_msg_start_program_t msg; - static timer_t timer; - static uint16_t sleep; - static uint8_t *ptr; - static uint8_t idx; - - PT_BEGIN(thread); - - /* wait */ - timer_set(&timer, MASTER_WAIT_BEFORE_SYNC); - while(!timer_expired(&timer)) - PT_YIELD(thread); - - /* start program on all devices */ - msg.address = 0xff; - msg.cmd = REMOTE_CMD_START_PROGRAM; - - while (1) { - ptr = &master_parameters[0]; - - for (idx = 0; idx < MASTER_PROGRAMS; idx++) { - /* stop current program and fading */ - script_stop(); - pwm_stop_fading(); - - /* start program colorwheel on all nodes */ - msg.script = pgm_read_byte(ptr++); - /* load parameters */ - for (uint8_t i = 0; i < sizeof(msg.params); i++) - msg.params.raw[i] = pgm_read_byte(ptr++); - - /* send */ - send_resync(MASTER_MODE_FIRST_ADDRESS); - PT_YIELD(thread); - send_msg((struct remote_msg_t *)&msg); - - /* start program locally */ - script_start(0, msg.script, &msg.params); - - /* sleep */ - sleep = MASTER_MODE_SLEEP; - while (sleep--) { - /* sleep 1s */ - timer_set(&timer, 100); - - while (!timer_expired(&timer)) - PT_YIELD(thread); - } - } - } - - PT_END(thread); -} -#endif - void remote_poll(void) { if (fifo_fill((fifo_t *)&global_uart.rx) > 0) { @@ -310,9 +212,6 @@ void remote_poll(void) /* enable remote command thread */ remote.synced = 1; PT_INIT(&remote.thread); -#if CONFIG_MASTER_MODE - global_remote.master = false; -#endif } else { /* just pass through data */ uart_putc(data); @@ -337,11 +236,6 @@ void remote_poll(void) if (remote.int_state == INT_PULLED_TIMER && timer_expired(&remote.int_timer)) { remote_release_int(); } - -#if CONFIG_MASTER_MODE - if (global_remote.master) - PT_SCHEDULE(remote_master_thread(&remote.master_thread)); -#endif } void remote_pull_int(void) diff --git a/firmware/fnordlicht-firmware/remote.h b/firmware/fnordlicht-firmware/remote.h index 6535489..3f54d72 100644 --- a/firmware/fnordlicht-firmware/remote.h +++ b/firmware/fnordlicht-firmware/remote.h @@ -39,11 +39,6 @@ struct remote_offsets_t struct global_remote_t { uint8_t address; struct remote_offsets_t offsets; - -#if CONFIG_MASTER_MODE - /* master mode */ - bool master; -#endif }; extern struct global_remote_t global_remote; diff --git a/firmware/fnordlicht-firmware/uart.c b/firmware/fnordlicht-firmware/uart.c index a004bcf..d25e2b5 100644 --- a/firmware/fnordlicht-firmware/uart.c +++ b/firmware/fnordlicht-firmware/uart.c @@ -51,11 +51,13 @@ volatile struct global_uart_t global_uart; /** output one character */ void uart_putc(uint8_t data) { +#if UART_TX_ENABLED /* store data */ fifo_enqueue((fifo_t *)&global_uart.tx, data); /* enable interrupt */ _UCSRB_UART0 |= _BV(_UDRIE_UART0); +#endif } /** init the hardware uart */ @@ -75,12 +77,18 @@ void uart_init(void) /* set mode */ _UCSRC_UART0 = UART_UCSRC; +#if UART_TX_ENABLED /* enable transmitter, receiver and receiver complete interrupt */ _UCSRB_UART0 = _BV(_TXEN_UART0) | _BV(_RXEN_UART0) | _BV(_RXCIE_UART0); + /* init tx fifo */ + fifo_init((fifo_t *)&global_uart.tx); +#else + /* enable receiver and receiver complete interrupt */ + _UCSRB_UART0 = _BV(_RXEN_UART0) | _BV(_RXCIE_UART0); +#endif - /* init fifos */ + /* init rx fifo */ fifo_init((fifo_t *)&global_uart.rx); - fifo_init((fifo_t *)&global_uart.tx); } @@ -95,10 +103,10 @@ ISR(_SIG_UART_RECV_UART0) } +#if UART_TX_ENABLED /** uart data register empty interrupt */ ISR(_SIG_UART_DATA_UART0) { - /* load next byte to transfer */ _UDR_UART0 = fifo_dequeue((fifo_t *)&global_uart.tx); @@ -107,8 +115,8 @@ ISR(_SIG_UART_DATA_UART0) /* disable this interrupt */ _UCSRB_UART0 &= ~_BV(_UDRIE_UART0); } - } +#endif #endif