Esempio n. 1
0
uint8_t 
spi_send(uint8_t outdata)
{
  DDR_CONFIG_IN(SOFT_SPI_MISO);

  uint8_t j, indata = indata;
  for(j = 0; j < 8; j++)
  {
    if(outdata & 0x80)
      PIN_SET(SOFT_SPI_MOSI);
    else
      PIN_CLEAR(SOFT_SPI_MOSI);

    PIN_SET(SOFT_SPI_SCK);
    indata <<= 1;

    if(PIN_HIGH(SOFT_SPI_MISO))
      indata |= 1;

    PIN_CLEAR(SOFT_SPI_SCK);

    outdata <<= 1;
  }

  DDR_CONFIG_OUT(SOFT_SPI_MISO);
  return indata;
}
Esempio n. 2
0
void noinline hd44780_hw_init(void)
{
    /* init io pins */
    CTRL_OUTPUT();
#ifdef HAVE_LCDON
    PIN_SET(LCDON);
#endif

    PIN_CLEAR(HD44780_RS);
#ifndef HD44780_MULTIENSUPPORT
    PIN_CLEAR(HD44780_EN1);
#endif
#ifdef HD44780_MULTIENSUPPORT
    PIN_CLEAR(HD44780_EN1);
    PIN_CLEAR(HD44780_EN2);
#endif
#ifdef HAVE_HD44780_RW
    PIN_CLEAR(HD44780_RW);
#endif
    PIN_CLEAR(HD44780_D4);
    PIN_CLEAR(HD44780_D5);
    PIN_CLEAR(HD44780_D6);
    PIN_CLEAR(HD44780_D7);
    DATA_OUTPUT();

#ifdef HD44780_BACKLIGHT_SUPPORT
    PIN_CLEAR(HD44780_BL);
#endif
}
Esempio n. 3
0
void noinline shift_nibble_out(uint8_t data)
{
// 	HD44780DEBUG("try to send: %X\n", data);
    uint8_t mask = 0x08;

    for (uint8_t n = 4; n > 0; n--) // Do this for 4 databits
    {
// 		HD44780DEBUG("send %i bit: %X\n", n, data & mask );
        if (data & mask) // Set or reset data signal
            PIN_SET(HD44780_2WIRE_D);
        else
            PIN_CLEAR(HD44780_2WIRE_D);
        PIN_SET(HD44780_2WIRE_CLK);
        LCD_DELAY();
        PIN_CLEAR(HD44780_2WIRE_CLK);
        mask >>= 1; // Shift right compare mask
    }

    // Clear data line, then do the last shift, Q7=1
    // Always clear data line before the last shift
    PIN_CLEAR(HD44780_2WIRE_D);

    PIN_SET(HD44780_2WIRE_CLK);
    LCD_DELAY();
    PIN_CLEAR(HD44780_2WIRE_CLK);
}
Esempio n. 4
0
static void leds_set_pin(leds_led_t led, bool on)
{
    switch( led ){
        case LED_0:
            if( on ){
                PIN_SET(LED_0);
            }else{
                PIN_CLEAR(LED_0);
            }
        break;
        case LED_1:
            if( on ){
                PIN_SET(LED_1);
            }else{
                PIN_CLEAR(LED_1);
            }
        break;
        case LED_2:
            if( on ){
                PIN_SET(LED_2);
            }else{
                PIN_CLEAR(LED_2);
            }
        break;
    }
}
Esempio n. 5
0
/*
* lome6 periodical countdown timer function
* counts down time in ~seconds since power button long is pressed (needed to prevent watchdog action)
* manages power on delay
*/
void lome6_timersec(void) {

	if (iCountdownTimer > 0) {

		iCountdownTimer--;
		if (iCountdownTimer <= 0)
			PIN_CLEAR(RELAIS_POWER);

	}
	
	// test power on delay counter
	// if server already on, dont do anything
	if (iPOD > 0 && PIN_HIGH(POWER_STATE)) {

		iPOD--;
		if (iPOD <= 0) {
		
			PIN_SET(RELAIS_POWER);
			_delay_ms(CONF_TIME2PRESS_POWER);
			PIN_CLEAR(RELAIS_POWER);
			
		}
		
	}

}
Esempio n. 6
0
int main(void)
{
    uint8_t escaped = 0;
    leds_init();

    DDR_CONFIG_OUT(RS485_TX_PIN);
    DDR_CONFIG_OUT(RS485_NRX_PIN);

    PIN_CLEAR(RS485_TX_PIN);
    PIN_CLEAR(RS485_NRX_PIN);

    UBRR0 = UART_BAUD_SELECT(RS485_BITRATE,F_CPU);
    UCSR0B |= (1<<TXEN0) | (1<<RXEN0);

    UBRR1 = UART_BAUD_SELECT(RS485_BITRATE,F_CPU);
    UCSR1B |= (1<<TXEN1) | (1<<RXEN1);
    
    wdt_reset();
    PIN_SET(RS485_TX_PIN);
    PIN_SET(RS485_NRX_PIN);

    while(1){
        wdt_reset();
        if( (UCSR1A & (1<<RXC1)) ){
            uint8_t data = UDR1;
            if( escaped ){
                escaped = 0;
                if( data == 'R' ){
                    wdt_enable(WDTO_2S);
                    while(1);
                }
            }else{
               if( data == '\\' ){
                    escaped = 1;
                    continue;
                }
            }
            UDR0 = data;
            PIN_SET(RS485_TX_PIN);
            PIN_SET(RS485_NRX_PIN);
            //_delay_us(4);
            leds_tx();
            while( !(UCSR0A & (1<<TXC0)) );
            UCSR0A |= (1<<TXC0);
            leds_txend();
            //_delay_us(4);
            PIN_CLEAR(RS485_TX_PIN);
            PIN_CLEAR(RS485_NRX_PIN);
        }
        if( (UCSR0A & (1<<RXC0)) ){
            UDR1 = UDR0;
            leds_rx();
            while( !(UCSR1A & (1<<TXC1)) );
            UCSR1A |= (1<<TXC1);
            leds_rxend();
        }

    }
}
Esempio n. 7
0
File: mmc.c Progetto: MaxGekk/ZigZag
// Initialize MMC card
unsigned char initMMC (void)
{

  //raise SS and MOSI for 80 clock cycles
  //SendByte(0xff) 10 times with SS high
  //RAISE SS
  int i;

  // Port 5 Function           Dir       On/Off
  //         5.1-Dout          Out       0 - off    1 - On -> init in SPI_Init
  //         5.2-Din           Inp       0 - off    1 - On -> init in SPI_Init
  //         5.3-Clk           Out       -                 -> init in SPI_Init
  //         5.0-mmcCS         Out       0 - Active 1 - none Active
/*
  P5SEL |= 0x0E;
  P5SEL &= ~0x11;
  P5OUT |= 0x11;
  P5DIR |= 0x1B;
*/
  /*
  PIN_SET(port5_attr.sel, 0x0e, PIN_HI);
  PIN_CLEAR(port5_attr.sel, 0x01);
  PIN_SET(port5_attr.dir, 0x0B, PIN_HI);
  PIN_CLEAR(port5_attr.dir, 0x04);
  port_set_attr(5, 0x0f, &port5_attr);
  port_write(5, 0x01, PIN_HI);
  */
//  PIN_SET(port5_attr.sel, 0x0e, PIN_HI);
#ifndef PORT_WRITE
  mmcPower(MMC_ON);
  MMC_PWR_PDIR |=  MMC_CARD_PWR;
  MMC_PWR_PSEL &= ~MMC_CARD_PWR;
//  MMC_POUT |=  MMC_CS;
  CS_HIGH();
  MMC_PDIR |=  MMC_CS;
  MMC_PSEL &= ~MMC_CS;
#else  // !PORT_WRITE
  PIN_SET  (mmc_pwr_port_attr.dir, MMC_CARD_PWR, PIN_HI);
  PIN_CLEAR(mmc_pwr_port_attr.sel, MMC_CARD_PWR);
  port_set_attr(MMC_PWR_PORT, MMC_CARD_PWR, &mmc_pwr_port_attr);
  mmcPower(MMC_ON);
  PIN_CLEAR(mmc_port_attr.sel, MMC_CS);
  PIN_SET  (mmc_port_attr.dir, MMC_CS, PIN_HI);
  port_set_attr(MMC_PORT, MMC_CS, &mmc_port_attr);
  CS_HIGH();
  //port_write(5, 0x01, PIN_HI);
#endif // !PORT_WRITE

//  initSPI();
//  SPI_init();
  //initialization sequence on PowerUp
//  CS_HIGH();
  for(i=0;i<=9;i++)
    spiSendByte(0xff);

  mmc_error = MMC_SUCCESS;

  return (mmc_GoIdle());
}
Esempio n. 8
0
void leds_init(void)
{
    DDR_CONFIG_OUT(LED1); 
    DDR_CONFIG_OUT(LED2); 
    DDR_CONFIG_OUT(LED3); 
    PIN_CLEAR(LED1);
    PIN_CLEAR(LED2);
    PIN_CLEAR(LED3);
}
Esempio n. 9
0
void clear_shift_register(void)
{
    PIN_CLEAR(HD44780_2WIRE_D);
    for (uint8_t a=7; a>0; a--)
    {
        PIN_SET(HD44780_2WIRE_CLK);
        LCD_DELAY();
        PIN_CLEAR(HD44780_2WIRE_CLK);
        LCD_DELAY();
    }
}
Esempio n. 10
0
void eltakoms_init(void)
{
  usart_init();

#if (USE_USART == 0 && defined(HAVE_RS485TE_USART0))
  PIN_CLEAR(RS485TE_USART0);  // disable RS485 transmitter for usart 0
#elif (USE_USART == 1  && defined(HAVE_RS485TE_USART1))
  PIN_CLEAR(RS485TE_USART1);  // disable RS485 transmitter for usart 1
#else
  #warning no RS485 transmit enable pin defined
#endif
  ELTAKOMS_DEBUG("init\n");
}
Esempio n. 11
0
void
zbus_core_init(void)
{
    /* Initialize the usart module */
    usart_init();
    /* Enable RX/TX Swtich as Output */
    DDR_CONFIG_OUT(RS485_TX_PIN);
    DDR_CONFIG_OUT(RS485_NRX_PIN);
    usart(UCSR,B) = _BV(usart(RXCIE)) | _BV(usart(RXEN));
    /* Default is reciever enabled*/
    PIN_CLEAR(RS485_TX_PIN);
    PIN_CLEAR(RS485_NRX_PIN);
}
Esempio n. 12
0
/* Инициализация портов */
void    sys_init()
{
    port_attr_t   port_attr;


    /* Настройка выхода на зелёный светодиод */
    PIN_SET( port_attr.dir, GREEN_PIN, PIN_HI );    /* Направление на вывод */
    PIN_CLEAR( port_attr.sel, GREEN_PIN );          /* Функция ввода/вывода */
    port_set_attr( GREEN_PORT, GREEN_PIN, &port_attr );
    port_write( GREEN_PORT, GREEN_PIN, PIN_LO );       /* По умолчанию гасим светодиод */

    /* Настройка выхода на красный светодиод */
    PIN_SET( port_attr.dir, RED_PIN, PIN_HI );    /* Направление на вывод */
    PIN_CLEAR( port_attr.sel, RED_PIN );          /* Функция ввода/вывода */
    port_set_attr( RED_PORT, RED_PIN, &port_attr );
    port_write( RED_PORT, RED_PIN, PIN_LO );       /* По умолчанию гасим светодиод */

    /* Настройка входа от геркона  */
    {   port_t  gercon_port = 0x00;
        event_type_t    event_type = 0;
        result_t    res = ENOSYS;    

        port_reset_iflag( GERCON_PORT, GERCON_PIN );

        PIN_CLEAR( port_attr.dir, GERCON_PIN );     /* Направление на ввод */
        PIN_CLEAR( port_attr.sel, GERCON_PIN );     /* Функция ввода/вывода */ 
        PIN_SET( port_attr.ie, GERCON_PIN, PIN_HI );    /* Разрешаем прерывания от кнопки */
        PIN_SET( port_attr.ies, GERCON_PIN, PIN_HI );   /* Ловим изменение с высокого на низкий уровень */ 
        port_set_attr( GERCON_PORT, GERCON_PIN, &port_attr );

        port_read( GERCON_PORT, GERCON_PIN, &gercon_port );

        /* Определение текущего состояния геркона */
        if( PIN_IS_SET( gercon_port, GERCON_PIN) ) {
            event_type = EV_TYPE_OPEN;
        } else {   
            PIN_SET( port_attr.ies, GERCON_PIN, PIN_LO );   /* Ловим изменение с низкого на высокий уровень */ 
            port_set_attr( GERCON_PORT, GERCON_PIN, &port_attr );
            event_type = EV_TYPE_CLOSE;
        }
        res = event_emit( PRIORITY_LOW, event_type, 0 );
        if( IS_ERROR(res) ) {
            /* Не смогли начать работу, зажигаем красный светодиод */
            port_write( RED_PORT, RED_PIN, PIN_HI );
        }
    }

    return;
}
Esempio n. 13
0
void noinline hd44780_hw_init(void)
{
    HD44780DEBUG("starte HW init\n");
    // set data direction to output & clear pins
    CTRL_OUTPUT();
    DATA_OUTPUT();

    PIN_CLEAR(HD44780_2WIRE_CLK);
    PIN_CLEAR(HD44780_2WIRE_D);

    _delay_ms(50); // Delay for power up time

    clear_shift_register();
    HD44780DEBUG("HW init finished\n");
}
Esempio n. 14
0
void noinline
shift_data_out(uint8_t byte)
{
  for (uint8_t a = 8; a > 0; a--)
  {
    if ((byte & (1 << (a - 1))) != 0)
      PIN_SET(HD44780_SER_D);
    else
      PIN_CLEAR(HD44780_SER_D);

    PIN_SET(HD44780_SER_CLK);
    _delay_us(1);
    PIN_CLEAR(HD44780_SER_CLK);
  }
}
Esempio n. 15
0
/* Инициализация прикладного объекта */
void    sys_init()
{
    port_attr_t   port_attr;
    /* Настройка ножки светодиода */

    PIN_SET( port_attr.dir, GREEN_LED, PIN_HI );    /* Направление на вывод */
    PIN_CLEAR( port_attr.sel, GREEN_LED);         /* Функция ввода/вывода */
    PIN_CLEAR( port_attr.ie, GREEN_LED);          /* Запрет прерываний */
    port_set_attr( LED_PORT, GREEN_LED, &port_attr );
    port_write( LED_PORT, GREEN_LED, PIN_LO );

    atimer_set( ASYNC_TIMER , atimer_counter() + WAIT_PERIOD );

    return;
}
Esempio n. 16
0
void fs20_init(void)
{
    /* default: enabled */
    fs20_global.enable = 1;

#ifdef FS20_SEND_SUPPORT
    /* configure port pin for sending */
    DDR_CONFIG_OUT(FS20_SEND);
    PIN_CLEAR(FS20_SEND);
#endif

#ifdef FS20_RECEIVE_SUPPORT
    /* reset global data structures */
    //fs20_global.fs20.raw = 0;
    memset((void *)&fs20_global.fs20.datagram, 0, sizeof(fs20_global.fs20.datagram));

    /* configure port pin for use as input to the analoge comparator */
    DDR_CONFIG_IN(FS20_RECV);
    PIN_CLEAR(FS20_RECV);

    /* enable analog comparator,
     * use fixed voltage reference (1V, connected to AIN0)
     * reset interrupt flag (ACI)
     * enable interrupt
     */
    ACSR = _BV(ACBG) | _BV(ACI) | _BV(ACIE);

    /* configure timer2 for receiving fs20,
     * prescaler 128
     * overflow interrupt enabled */
    TC2_COUNTER_CURRENT = 0;
    TC2_PRESCALER_128;
    TC2_MODE_OFF;
    TC2_OUTPUT_COMPARE_NONE;
    TC2_INT_OVERFLOW_ON;

#ifdef FS20_RECEIVE_WS300_SUPPORT

    /* reset everything to zero */
    memset((void *)&fs20_global.ws300, 0, sizeof(fs20_global.ws300));
#endif
#endif

#ifdef FS20_RECV_PROFILE
    fs20_global.int_counter = 0;
    fs20_global.ovf_counter = 0;
#endif
}
bl_info_entry_t* bootloader_info_entry_get(uint32_t* p_bl_info_page, bl_info_type_t type)
{
    if (mp_bl_info_page &&
        mp_bl_info_page->metadata.entry_header_length != 0xFF)
    {
        bootloader_info_header_t* p_header =
            (bootloader_info_header_t*)
            ((uint32_t) p_bl_info_page + ((bootloader_info_t*) p_bl_info_page)->metadata.metadata_len);
        uint32_t iterations = 0;
        bl_info_type_t iter_type = (bl_info_type_t) p_header->type;
        while (iter_type != type)
        {
            p_header = bootloader_info_iterate(p_header);
            if ((uint32_t) p_header > ((uint32_t) p_bl_info_page) + PAGE_SIZE ||
                (
                 (iter_type == BL_INFO_TYPE_LAST) &&
                 (iter_type != type)
                ) ||
                ++iterations > PAGE_SIZE / 2)
            {
                PIN_CLEAR(PIN_ENTRY_GET);
                return NULL; /* out of bounds */
            }
            iter_type = (bl_info_type_t) p_header->type;
        }
        return (bl_info_entry_t*) ((uint32_t) p_header + 4 * mp_bl_info_page->metadata.entry_header_length);
    }
    else
    {
        return NULL;
    }
}
Esempio n. 18
0
void door_init(void)
{
    door_doorstate = 0;

    DDR_CONFIG_IN(DOOR_REED_CONTACT);
    PIN_SET(DOOR_REED_CONTACT);

    DDR_CONFIG_IN(DOOR_LOCK_BRIDGE);
    PIN_SET(DOOR_LOCK_BRIDGE);

    DDR_CONFIG_IN(DOOR_LOCK_UNLOCKED_CONTACT);
    PIN_SET(DOOR_LOCK_UNLOCKED_CONTACT);

    DDR_CONFIG_IN(DOOR_LOCK_LOCKED_CONTACT);
    PIN_SET(DOOR_LOCK_LOCKED_CONTACT);

    DDR_CONFIG_IN(DOOR_HANDLE_CONTACT);
    PIN_SET(DOOR_HANDLE_CONTACT);

    DDR_CONFIG_IN(DOOR_DOOR_OPEN_CONTACT);
    PIN_SET(DOOR_DOOR_OPEN_CONTACT);

    PIN_CLEAR(DOOR_LOCK);
    DDR_CONFIG_OUT(DOOR_LOCK);
}
Esempio n. 19
0
void
send_sign(uint8_t c){
  int8_t i;
  CWDEBUG ("cw: %X: ", c);
  if (c == 0) {
    _delay_ms(WORDBREAK);
  } else {

    for (i = 0; i < 8; i++) {
      if (c == 1) break;
      PIN_SET(CW);
      if ((c & 0x01) == 1 ) { // read lowest bit
  		CWDEBUG ("dah ");
        _delay_ms(DAH); // wait dah
      } else {
  		CWDEBUG ("dit ");
        _delay_ms(DIT); // wait dit
      }
      PIN_CLEAR(CW);
      _delay_ms(DIT); // wait dit during morse char
      c = c >> 1;  // right shift 
    }
  }  
  CWDEBUG (".\n");
  _delay_ms(DAH); // break between morce chars
}
Esempio n. 20
0
void ST7626_reset(void)
{
    PIN_CLEAR(ST7626_RESET);
    _delay_us(2);
    PIN_SET(ST7626_RESET);
    _delay_us(2);
}
Esempio n. 21
0
void rc5_send_zero(void)
{
    PIN_SET(RC5_SEND);
    _delay_loop_2(RC5_PULSE);
    PIN_CLEAR(RC5_SEND);
    _delay_loop_2(RC5_PULSE);
}
Esempio n. 22
0
void rc5_send(uint8_t addr, uint8_t cmd)
{
    static uint8_t toggle = 0;

    /* send two one sync bits */
    rc5_send_one();
    rc5_send_one();

    /* send toggle bit */
    if (toggle)
        rc5_send_one();
    else
        rc5_send_zero();

    toggle = !toggle;

    for (int8_t i = 4; i >= 0; i--) {
        if (addr & _BV(i))
            rc5_send_one();
        else
            rc5_send_zero();
    }

    for (int8_t i = 5; i >= 0; i--) {
        if (cmd & _BV(i))
            rc5_send_one();
        else
            rc5_send_zero();
    }

    /* turn off sender */
    PIN_CLEAR(RC5_SEND);

}
Esempio n. 23
0
void leds_tick(void)
{
    leds_counter++;
    if( leds_open_state == LED_ON){
        PIN_SET(LED_OPEN_PIN);
    }else if( leds_open_state == LED_OFF ){
        PIN_CLEAR(LED_OPEN_PIN);
    }else if( leds_open_state == LED_SHORT_FLASH ){
        if( (leds_counter % 1024) < 50 ){
            PIN_SET(LED_OPEN_PIN);
        }else{
            PIN_CLEAR(LED_OPEN_PIN);
        }
    }

}
Esempio n. 24
0
void
dcf77_init(void)
{
  DCFDEBUG("init dcf77\n");
#ifdef DCF1_USE_PON_SUPPORT
  DCFDEBUG("PON\n");
  /* if module needs a peak on PON to enable dcf77 receiver
   * configure pin as output, set low */
  PIN_SET(DCF1_PON);
#endif

#if defined(DCF77_PCINT_PIN)
  DCFDEBUG("configure_pcint\n");
  /* configure */
  dcf77_configure_pcint();
#elif defined(DCF77_INT_PIN)
  DCFDEBUG("HAVE_DCF77_INT\n");
  /* Initialize "real" Interrupt */
  _EIMSK |= _BV(DCF77_INT_PIN);
  _EICRA = (_EICRA & ~DCF77_INT_ISCMASK) | DCF77_INT_ISC;
#else
  DCFDEBUG("Analog Comparator\n");
  // Analog Comparator init
  ACSR |= _BV(ACIE);
#endif

#ifdef DCF1_USE_PON_SUPPORT
  for (uint8_t i = 0; i < 100; i++)
  {
    wdt_kick();
    _delay_ms(10);
  }
  PIN_CLEAR(DCF1_PON);
#endif
}
Esempio n. 25
0
void rc5_init(void)
{

    /* configure send pin as output, set low */
    DDR_CONFIG_OUT(RC5_SEND);
    PIN_CLEAR(RC5_SEND);

    /* enable timer0/timer2, set prescaler and enable overflow interrupt */
#ifdef RC5_USE_TIMER2
    TCCR2 = _BV(CS22) | _BV(CS21) | _BV(CS20);
#else
    TCCR0A = 0;
    TCCR0B = _BV(CS02) | _BV(CS00);
#endif

    /* configure int0 to fire at any logical change */
    EICRA |= _BV(RC5_ISC0);
    EICRA &= ~_BV(RC5_ISC1);

    /* clear any old interrupts and enable int0 interrupt */
    EIFR = _BV(RC5_INT_PIN);
    EIMSK |= _BV(RC5_INT_PIN);

    /* reset everything to zero */
    memset((void *)&rc5_global, 0, sizeof(rc5_global));

    /* enable rc5 receive, init variables */
    rc5_global.enabled = 1;
}
Esempio n. 26
0
void
irmp_init(void)
{
#ifdef IRMP_RX_SUPPORT
  /* configure TSOP input, disable pullup */
  DDR_CONFIG_IN(IRMP_RX);
  PIN_CLEAR(IRMP_RX);
#endif

#ifdef STATUSLED_IRMP_RX_SUPPORT
  DDR_CONFIG_OUT(STATUSLED_IRMP_RX);
  IRMP_RX_LED_OFF;
#endif

#ifdef STATUSLED_IRMP_TX_SUPPORT
  DDR_CONFIG_OUT(STATUSLED_IRMP_TX);
  IRMP_TX_LED_OFF;
#endif

  /* init timer0/2 to expire after 1000/IRMP_HZ ms */
#ifdef IRMP_USE_TIMER2
  SET_HW_PRESCALER;
  TC2_COUNTER_COMPARE = SW_PRESCALER - 1;
  TC2_COUNTER_CURRENT = 0;
  TC2_INT_COMPARE_ON;           /* enable interrupt */
#else
  SET_HW_PRESCALER;
  TC0_COUNTER_COMPARE = SW_PRESCALER - 1;
  TC0_COUNTER_CURRENT = 0;
  TC0_INT_COMPARE_ON;           /* enable interrupt */
#endif

#ifdef IRMP_TX_SUPPORT
  PIN_CLEAR(IRMP_TX);
  DDR_CONFIG_OUT(IRMP_TX);
#ifndef IRMP_EXTERNAL_MODULATOR
#ifdef IRMP_USE_TIMER2
  TC0_MODE_CTC;
  TC0_PRESCALER_1;
#else
  TC2_MODE_CTC;
  TC2_PRESCALER_1;
#endif
#endif
  irmp_tx_set_freq(IRSND_FREQ_36_KHZ);  /* default frequency */
#endif
}
Esempio n. 27
0
void
bulbdial_clock(uint8_t delay){
  struct clock_datetime_t date;
  clock_current_localtime(&date);
  clear();
  set(0x0001 << (date.sec/5));
  PIN_SET(BULBDIAL_MINUTES);
  for (uint8_t i = delay; i; i--)
    _delay_ms(1);
  PIN_CLEAR(BULBDIAL_MINUTES);
  clear();
  set(0x0001 << (date.min/5));
  PIN_SET(BULBDIAL_HOURS);
  for (uint8_t i = delay; i; i--)
    _delay_ms(1);
  PIN_CLEAR(BULBDIAL_HOURS);
}
Esempio n. 28
0
void fs20_init(void)
{
    /* default: enabled */
    fs20_global.enable = 1;

#ifdef FS20_SEND_SUPPORT
    /* configure port pin for sending */
    DDR_CONFIG_OUT(FS20_SEND);
    PIN_CLEAR(FS20_SEND);
#endif

#ifdef FS20_RECEIVE_SUPPORT
    /* reset global data structures */
    memset((void *)&fs20_global.fs20.datagram, 0, sizeof(fs20_global.fs20));

    /* configure port pin for use as input to the analoge comparator */
    DDR_CONFIG_IN(FS20_RECV);
    PIN_CLEAR(FS20_RECV);

    /* enable analog comparator,
     * use fixed voltage reference (1V, connected to AIN0)
     * reset interrupt flag (ACI)
     * enable interrupt
     */
    ACSR = _BV(ACBG) | _BV(ACI) | _BV(ACIE);

    /* configure timer2 for receiving fs20,
     * prescaler 128
     * overflow interrupt enabled */
    TCNT2 = 0;
    TCCR2A = 0;
    TCCR2B = _BV(CS20) | _BV(CS22);
    _TIMSK_TIMER2 = _BV(TOIE2);

#ifdef FS20_RECEIVE_WS300_SUPPORT

    /* reset everything to zero */
    memset((void *)&fs20_global.ws300, 0, sizeof(fs20_global.ws300));
#endif
#endif

#ifdef FS20_RECV_PROFILE
    fs20_global.int_counter = 0;
    fs20_global.ovf_counter = 0;
#endif
}
Esempio n. 29
0
void fs20_send_zero(void)
{
  PIN_SET(FS20_SEND);
  _delay_loop_2(FS20_DELAY_ZERO);
  PIN_CLEAR(FS20_SEND);
  _delay_loop_2(FS20_DELAY_ZERO);

}
Esempio n. 30
0
void
hd44780_backlight(uint8_t state)
{
  hd44780_backlight_state = state;

#ifdef HD44780_BACKLIGHT_INV
  if (hd44780_backlight_state)
    PIN_CLEAR(HD44780_BL);
  else
    PIN_SET(HD44780_BL);
#else
  if (hd44780_backlight_state)
    PIN_SET(HD44780_BL);
  else
    PIN_CLEAR(HD44780_BL);
#endif
}