Ejemplo n.º 1
0
void ow_write_bit(uint8_t bit)
{
	bus_low();
	if(bit)
	{
		_delay_us(T/6);		// Logic 1
		bus_release();
		_delay_us(5*T/6);	// Finish time slot
	}
	else
	{
		_delay_us(T);		// Logic 0
		bus_release();
	}
}
Ejemplo n.º 2
0
/*	One Wire functions	*/
uint8_t ow_reset(void)
{
	// Wait until the bus is high
	bus_release();
	while( !(OW_BUS_PIN & OW_BUS_PIN_MASK));
	uint8_t r = 0;

	bus_low();
	_delay_us(10*T);
	bus_release();
	_delay_us(2*T);
	r = !bus_read();
	_delay_us(6*T);

	return r;
}
Ejemplo n.º 3
0
void tm_fetch_ram ( void ) {
    bus_grab_and_wait();
    bus_read_block ( ram_textmode, TM_VRAM_FB, TM_PAGE_STRIDE );
    bus_read_block ( ram_textattr, TM_VRAM_ATTR, TM_PAGE_STRIDE );
    bus_read_block ( &ram_spritecount, TM_SPRITE_ACTIVE, 1 );
    bus_read_block ( ram_spritelist, TM_SPRITE_LIST_BASE, ( ram_spritecount * TM_SPRITE_CELL_STRIDE) );
    bus_release();
    return;
}
Ejemplo n.º 4
0
uint8_t	ow_read_bit(void)
{
	int8_t r;

	bus_low();
	_delay_us(T/6);
	bus_release();
	_delay_us(T/12);
	r = bus_read();
	_delay_us(T/12+T/6+T/2);

	return r;
}
Ejemplo n.º 5
0
static uint8_t read_slot()
{
    bus_drive0();
    _delay_us(MIN_READ_DRIVE_DELAY);
    bus_release();
    _delay_us(MAX_READ_RESP_DELAY);

    const uint8_t value = bus_latch();

    // This delay is longer than required, but that's fine
    _delay_us(MIN_RWSLOT_MIN_SLOT_LENGTH + MIN_RWSLOT_RECOVERY_DELAY);

    return value;
}
Ejemplo n.º 6
0
uint8_t onewire_reset()
{
    // Make the pin an output and drive low for MIN_RESET_PULSE
    bus_drive0();
    _delay_us(MIN_RESET_PULSE);

    bus_release();
    // Stop driving the pin and let the DS180B20 do its thing
    _delay_us(MIN_PRESENCE_RESP_DELAY + MIN_PRESENCE_PULSE);

    const uint8_t presence_value = bus_latch();

    // Presence lasts minimum 480us -- this is overkill, that fine.
    _delay_us(MIN_RESET_PULSE);
    return (presence_value == 0) ? 1 : 0;
}
Ejemplo n.º 7
0
static void write_slot(const uint8_t value)
{
    bus_drive0();

    if(value == 0)
        {
            _delay_us(MIN_RWSLOT_MIN_SLOT_LENGTH);
        }
    else
        {
            _delay_us(MIN_WRITE1_DRIVE_DELAY);
        }


    bus_release();

    // Extraneous for write1 case, but harmless
    _delay_us(MIN_RWSLOT_MIN_SLOT_LENGTH + MIN_RWSLOT_RECOVERY_DELAY);
}
Ejemplo n.º 8
0
int main(void) {

  system_cm3_setup();

  log_setup();
  queue_setup();

  init_usart1 ( 38400 ); // initialize USART1 @ 9600 baud
  init_usart2 ( 38400 );
  //USART_puts ( USART1, "Init usart1 complete! Hello World!\r\n" );
  USART_puts ( USART2, "Init usart2 complete! Hello World!\r\n" );

  fb_setup();

#ifdef VGA_DMA
  vga_setup ( VGA_USE_DMA );
#else
  vga_setup ( VGA_NO_DMA );
#endif

#ifdef BUS_FRAMEBUFFER
  bus_setup();
#endif

  //fb_test_pattern ( fb_active, fbt_topbottom );
  fb_test_pattern ( fb_active, fbt_offset_squares );
  //fb_test_pattern ( fb_active, fbt_vlines );
  //fb_test_pattern ( fb_active, fbt_v1lines );
  //fb_test_pattern ( fb_active, fbt_onoff1 );
  //fb_test_pattern ( fb_active, fbt_spriteram );

  while ( 1 ) {
    // weeeeee!

    // any work for us to do?
#ifdef RUNMODE_COMMAND_SERIAL
    if ( vblank ) {

      if ( queueready() ) {
        command_queue_run();
      }

    }
#endif

#ifdef RUNMODE_FRAMEBUFFER_FOREVER
    if ( vblank ) {
      queueit ( "BD" );
      command_queue_run();
    }
#endif

    // update framebuffers
#if 0
    if ( vblank ) {
      unsigned char i = 0;
      fb_clone ( fb_2, fb_active );
      while ( vblank ) {
        __asm__("nop");
      }
      fb_test_pattern ( fb_2, i & 0x03 );
      i++;
    }
#endif

    // check for external RAM updates?
#ifdef zzBUS_FRAMEBUFFER
    static uint16_t _done = 0;
    _done++;
    if ( vblank && _done > 30 && _done < 40  ) {

      bus_grab_and_wait();

      uint32_t addr = 0x1C0000;
      uint8_t v;
      uint8_t i;
      char b [ 2 ];

      USART_puts_optional ( USART2, "+REM cart dump: " );

      for ( i = 0; i < 20; i++ ) {
        v = bus_perform_read ( addr );

        b [ 0 ] = v;
        b [ 1 ] = '\0';
        USART_puts_optional ( USART2, b );

        addr++;
      }

      USART_puts_optional ( USART2, "+++\n" );

      bus_release();

    }
#endif

    // handle queued logs
#if 0
    if ( logready() ) {
      char *log;
      while ( ( log = logpull() ) ) {
        USART_puts ( USART2, log );
      }
    }
#endif

    __asm__("nop");
  }

} // main