Ejemplo n.º 1
0
/**
 * Initialisiert die Enable-Leitungen
 */
void ENA_init(void) {
#ifdef EXPANSION_BOARD_AVAILABLE
	DDRD |= _BV(PD2);
#endif
	shift_init();
	ENA_set(0x00);
}
Ejemplo n.º 2
0
int main(void)
{
  uart_init();
  shift_init();
  timer_init();
  display_init();
  keypad_init();
  serial_init();
  edit_init();
  clock_init();
  watchdog_init(WDTO_15MS, &oops);

  sei();  // enable interrupts

  printf("\r\n*** BOOTED ***\r\nSpaceTime, yay!\r\n");

  timer_beep(10);

  while(1)
  {
    display_update();

    serial_update();

    edit_update();

    clock_update();
  }
}
Ejemplo n.º 3
0
/*! 
 * Init Display
 */
void display_init(void){
	shift_init();

	DISPLAY_DDR |= DISPLAY_OUT;		// Ausgänge
	DISPLAY_DDR &= ~DISPLAY_IN;		// Eingänge

	delay(30);		// Display steht erst 10ms nach dem Booten bereit
	
	// Register in 8-Bit-Modus 3x Übertragen, dazwischen warten
	shift_data_out(0x38,SHIFT_LATCH,SHIFT_REGISTER_DISPLAY);
	DISPLAY_PORT= DPC;
	delay(5);		
	shift_data_out(0x38,SHIFT_LATCH,SHIFT_REGISTER_DISPLAY);
	DISPLAY_PORT= DPC;
	delay(5);		
	shift_data_out(0x38,SHIFT_LATCH,SHIFT_REGISTER_DISPLAY);
	DISPLAY_PORT= DPC;
	delay(5);		
	
	display_cmd(0x0f);  		//Display On, Cursor On, Cursor Blink
	
	display_cmd(DISPLAY_CLEAR); // Display l�schen, Cursor Home
	
	display_data('i');
}
Ejemplo n.º 4
0
void led_matrix_init()
{
	shift_init();

	led_matrix_framebffr = led_matrix_framebffr_;
	  // Timer 0 konfigurieren
	


	COLLUMN0_DDR |= (1<<COLLUMN0_PIN);
	COLLUMN1_DDR |= (1<<COLLUMN1_PIN);
	COLLUMN2_DDR |= (1<<COLLUMN2_PIN);
	COLLUMN3_DDR |= (1<<COLLUMN3_PIN);

	COLLUMN0_PORT &= ~(1<<COLLUMN0_PIN);
	COLLUMN1_PORT &= ~(1<<COLLUMN1_PIN);
	COLLUMN2_PORT &= ~(1<<COLLUMN2_PIN);
	COLLUMN3_PORT &= ~(1<<COLLUMN3_PIN);


 	 // CTC Modus
  	TCCR2 |= (1<<WGM21)|(1<<CS22); // Prescaler 64
	OCR2 = 77;//((0.000625 / (1/F_CPU)) / 64)-1;   //  (TimeToGet/(1/F_CPU))/PRESCALER == to write in OCR0A
 	
  	// Compare Interrupt erlauben
  	TIMSK |= (1<<OCIE2);
 
  	// Global Interrupts aktivieren
	WDTCR |= (1<<WDCE)|(1<<WDE);
	WDTCR |= (1<<WDP0)|(1<<WDP1)|(1<<WDE); //enable watchdog approximatily every 12ms

  	sei();
}
Ejemplo n.º 5
0
int main(void){
	usart_init();
	shift_init();
	while(1){
		uint8_t data = shift_in();
		usart_transmit_byte(data);
		_delay_ms(500);
		
	}
	return 1;
}
Ejemplo n.º 6
0
void shift_out(unsigned char c)
{
	shift_init();
	c |= bl;
	int i;
	for (i = 0; i < 8; i++) {
		gpio_write(gpio_dev, CLOCK_BIT, 0);
		gpio_write(gpio_dev, CLOCK_BIT, 0);
		gpio_write(gpio_dev, DATA_BIT, c & 1);
		gpio_write(gpio_dev, CLOCK_BIT, 1);
		c >>= 1;
	}
	gpio_write(gpio_dev, LATCH_BIT, 1);
	gpio_write(gpio_dev, LATCH_BIT, 1);
	gpio_write(gpio_dev, LATCH_BIT, 0);
}
Ejemplo n.º 7
0
void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop watchdog timer
  
  BCSCTL1 = CALBC1_16MHZ;                   // Set range
  DCOCTL = CALDCO_16MHZ;                    // Set DCO step and modulation
  
  xtal_2_gpio_init();
  spi_init();
  shift_init();
  
  // Initialize Pushbutton on Pin 1.3
  P1OUT |= BIT3;
  P1REN |= BIT3;                            // P1.x pullup
  P1IE  |= BIT3;                            // P1.x interrupt enabled
  P1IES |= BIT3;                            // P1.x Hi/lo edge
  P1IFG &= ~BIT3;                           // P1.x IFG cleared
  
  _BIS_SR(LPM0_bits | GIE);                // Enter LPM4 w/interrupt
}
Ejemplo n.º 8
0
/*!
 * Initialisiert das Display
 */
void display_init(void)
{
   commandMQ = msgQueueAdd();
   dataMQ = msgQueueAdd();
   shift_init();

   DISPLAY_DDR |= DISPLAY_OUT; // Ausgaenge
   DISPLAY_DDR = (BK_U8B) (DISPLAY_DDR & ~DISPLAY_IN); // Eingaenge
   _delay_ms(12); // Display steht erst 10ms nach dem Booten bereit hier kann nicht die ctbotKernel wait funktion genutzt werden da die interrupts erst später aktiviert werden und somit die wait funktion noch nicht funktioniert
   /* Register in 8-Bit-Modus 3x uebertragen, dazwischen warten */
   BK_U8B i;
   for (i = 3; i > 0; --i)
   {
      shift_data_out(0x38, SHIFT_LATCH, SHIFT_REGISTER_DISPLAY);
      DISPLAY_PORT = DPC;
      _delay_ms(5);
   }
   display_cmd(DISPLAY_MODE); // Display an und Cursor-Modus setzen

   display_cmd(DISPLAY_CLEAR); // Display loeschen, Cursor Home
}
Ejemplo n.º 9
0
Archivo: main.c Proyecto: lukeyyang/475
int 
main()
{
        /*
         * used by rotary encoder
        int rot_a = 0;
        int rot_b = 0;
        int prev_val = 0;
        */

        /* Initialize Clock Rate */
        usart_init(47);
        shift_init();

        DDRD  &= (1 << PD5);   // Set PORTD bit 5 for input, take in rotary bit A
        DDRD  &= (1 << PD6);   // Set PORTD bit 6 for input, take in rotary bit B
        PORTD |= (1 << PD5);   // Activate pull-ups in PORTD pi
        PORTD |= (1 << PD6);   // Activate pull-ups in PORTD pi

        /* main loop
         * every cycle, read at the beginning, write at the end
         * */
        uint8_t zone_reg = 0;
        while (1) {
                int temperature = get_temperature();
                int moisture = get_moisture();
                char zone_char = usart_in();
                usart_putchar('\n');

                char temp_write_buf[36];
                snprintf(temp_write_buf, 
                                36, 
                                "Temp: %ld F, Moisture: %d, ",
                                CtoF(temperature),
                                moisture);
                usart_out(temp_write_buf);

                _delay_ms(200);

                /**
                 * Rotary Encoder - Deprecated
                 * Read inputs
                rot_a = (PIND & (1 << PD5));  // Read value on PD5
                rot_b = (PIND & (1 << PD6));  // Read value on PD6

                if ((prev_val == 0) && (rot_a == 32)) {
                        if (rot_b == 64) {
                                zone_char--; 
                        } else {
                                zone_char++; 
                        }
                }

                prev_val = rot_a;
                */

                /* we only accept zones 1 through 8, 0 to turn off */
                char zone_write_buf[17];
                if (zone_char >= '0' && zone_char <= '8') {
                        snprintf(zone_write_buf, 
                                        17, 
                                        "Current Zone: %c\r\n", 
                                        zone_char);
                        usart_out(zone_write_buf);
                        _delay_ms(200);
                        if (zone_char > '0') {
                                uint8_t zone_onehot 
                                        = (uint8_t) (1 << (zone_char - '1'));
                                shift_write(zone_onehot);
                                zone_reg = (uint8_t) (zone_char - '0');
                        } else {
                                if (zone_char == '0') {
                                        zone_reg = 0;
                                }
                                shift_write(0);
                        }
                } else {
                        snprintf(zone_write_buf,
                                        17,
                                        "Current Zone: %c\r\n",
                                        (char) (zone_reg + '0'));
                        usart_out(zone_write_buf);
                        _delay_ms(200);
                }
        }

        return 0;
}
Ejemplo n.º 10
0
/*!
 * Initialisiert die LEDs
 */
void LED_init(){
	shift_init();
	LED_off(LED_ALL);
}
Ejemplo n.º 11
0
int main(void)
{
//	EXT_MEM_INIT;
	
	usart0_init(USART_RS485_SLAVE, 38400);
	usart0_setprotocol_modbus();
	usart1_init(USART_RS232, 115200);
	USART1_SET_8N1;
	USART1_RX_INT_DISABLE;

	timer_init();
	kbd_init();
	shift_init();
	sensor_init();
	menu_init();
	menu_items_init();

	beep_init();
	
	GLOBAL_INT_ENABLE;

	beep_ms(1000);
	_delay_ms(500);
	beep_ms(200);
	_delay_ms(200);
	beep_ms(200);
	_delay_ms(200);

	lcd_init();

	for (;;)
	{
		//do_kbd();
		do_lcd();
		do_shift();
		do_sensor();
		
		menu_doitem();

		process_usart();
		process_soft_controls();
		process_siren();
		//process_foil();
		//process_kbd();
		
		// simple process foil
		
		soft_sensors = sensors;
		
		if (TEST_SOFT_CONTROL(SOFT_CONTROL_BUNKER_MOTOR) &&
			TEST_SENSOR(SENSOR_END_OF_FOIL))
			
			SOFT_CONTROL_OFF(SOFT_CONTROL_BUNKER_MOTOR);
/*			
		if (!TEST_SENSOR(SENSOR_END_OF_FOIL) &&
			TEST_SENSOR(SENSOR_SEC_REEL))
			
			SOFT_CONTROL_ON(SOFT_CONTROL_BUNKER_MOTOR);
*/
	}
	return 0;
}