void sci_initialize(int priority, long baudrate)
{
    interrupt_priority_ = priority;

    // スタンバイ解除
    STB.CR3.BYTE = 0xef;

    // 通信と割り込みを禁止し、内部クロックで動作させる
    SCI1.SCSCR.BYTE = 0x00;

    // 8bit, no parity, 1 stop bit
    SCI1.SCSMR.BYTE = 0x00;
    SCI1.SCSDCR.BYTE = 0xf2;

    // set baudrate
    SCI1.SCBRR = (int)((P_MHz / 1024.0) * 2 * 1000000 / 64 / baudrate) - 1;

    // 1 bit のウェイト
    // !!! 1 bit のウェイト数を適切に設定すること
    enum { OneBitWait = 1000 };
    volatile int i;
    for (i = 0; i < OneBitWait; ++i) {
        ;
    }

    // TXD1(PA4)
    PFC.PACRL2.WORD &= ~0x0007;
    PFC.PACRL2.WORD |= 0x0001;

    // RXD1(PA3)
    PFC.PACRL1.WORD &= ~0x7000;
    PFC.PACRL1.WORD |= 0x1000;

    // リングバッファの初期化
    ring_initialize(&read_ring_, read_buffer_, BUFFER_SIZE_SHIFT);
    ring_initialize(&write_ring_, write_buffer_, BUFFER_SIZE_SHIFT);

    // 割り込みの初期化
    //INTC.IPRL.BIT._SCI1 = priority;
    INTC.IPRL.WORD &= ~0x0f00;
    INTC.IPRL.WORD |= priority << 8;
    SCI1.SCSCR.BYTE |= 0x40;
    // !!! 以下の割り込みを許可する必要があるかは、要検討
    // !!! SCSCR の TIE, TEIE, MPIE で割り込みを許可

    // 通信を許可
    SCI1.SCSCR.BYTE |= 0x30;
}
예제 #2
0
/*
 * 串口初始化,需要初始化一个ringbuffer来存储接收到的数据
 */
static void serial_initialize(urg_serial_t *serial)
{
    serial->fd = INVALID_FD;
    serial->has_last_ch = False;

    ring_initialize(&serial->ring, serial->buffer, RING_BUFFER_SIZE_SHIFT);
}
예제 #3
0
void serial_initialize(serial_t *serial)
{
  serial->hCom_ = INVALID_HANDLE_VALUE;
  serial->errno_ = SerialNoError;
  serial->has_last_ch_ = False;

  ring_initialize(&serial->ring_, serial->buffer_, RingBufferSizeShift);
}
예제 #4
0
void serial_initialize(serial_t *serial)
{
  serial->fd_ = InvalidFd;
  serial->errno_ = SerialNoError;
  serial->has_last_ch_ = False;

  ring_initialize(&serial->ring_, serial->buffer_, RingBufferSizeShift);
}
예제 #5
0
파일: server.c 프로젝트: prophile/dim3
bool server_initialize(char *err_str)
{
		// clear server, js, hud structures
		
	memset(&server,0x0,sizeof(server_type));
	memset(&js,0x0,sizeof(js_type));
	memset(&hud,0x0,sizeof(hud_type));
	
		// allocate memory
		
	if (!server_memory_allocate()) {
		server_memory_release();
		strcpy(err_str,"Out of Memory");
		return(FALSE);
	}
	
		// start script engine
		
	if (!scripts_engine_initialize(err_str)) {
		server_memory_release();
		return(FALSE);
	}
	
		// initialize project settings
		
	hud_initialize();
	particle_initialize();
	ring_initialize();
	halo_initialize();
	mark_initialize();
	crosshair_initialize();
	
		// load project XML
		
	read_settings_interface();
	read_settings_particle();
	read_settings_ring();
	read_settings_halo();
	read_settings_mark();
	read_settings_crosshair();
	
		// game states
		
	server.game_open=FALSE;
	server.map_open=FALSE;

	server.map_change=FALSE;
	server.skip_media=FALSE;
	
	return(TRUE);
}
예제 #6
0
static void tcpclient_buffer_init(urg_tcpclient_t* cli)
{
    ring_initialize(&cli->rb, cli->buf, RB_BITSHIFT);
}