• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ port_read函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中port_read函数的典型用法代码示例。如果您正苦于以下问题:C++ port_read函数的具体用法?C++ port_read怎么用?C++ port_read使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了port_read函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: stimer_fired

void    stimer_fired( const uint8_t tnum )
{
    port_t  ledport;
    result_t    res;

    if( tnum != TIMER_NUM ) return;

    if( state == GERCON_OPEN ) {
        port_read( RED_PORT, RED_PIN, &ledport );
        ledport ^= RED_PIN;
        port_write( RED_PORT, RED_PIN, ledport );
        res = stimer_set( TIMER_NUM, RED_PERIOD );
    } else if( state == GERCON_CLOSE ) {
        if( MAX_GREEN_COUNT <= green_count )
            port_write( GREEN_PORT, GREEN_PIN, PIN_HI );
        green_count++;
        port_read( GREEN_PORT, GREEN_PIN, &ledport );
        ledport ^= GREEN_PIN;
        port_write( GREEN_PORT, GREEN_PIN, ledport );
        res = stimer_set( TIMER_NUM, GREEN_PERIOD );
    }
    if( IS_ERROR(res) )
        port_write( RED_PORT, RED_PIN, PIN_HI );
    return;
}
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:25,代码来源:ipmce_gercon.c


示例2: main

void main(void)
{
    int i;
    int value_new, value_tmp, value_old;
    int stable;

    port_mode(&port0, PullNone);
    // Only PortA or PortB is available now
    port_init(&port0, PortA, 0xFF, PIN_INPUT);

    value_old = port_read(&port0); 
    while(1){
        // De-bonse
        value_new = port_read(&port0); 
        stable = 0;
        while (stable < 3){
            value_tmp = port_read(&port0); 
            if (value_new != value_tmp) {
                value_new = value_tmp;
                stable = 0;
            }
            else {
                stable++;
            }
        } 

        if (value_old != value_new) {
            DBG_8195A("0x%x\r\n", value_new);
            value_old = value_new;
        }
        wait_ms(50);
    }
}
开发者ID:alex1818,项目名称:rtk-8711af,代码行数:33,代码来源:main.c


示例3: event_handler

void    event_handler( event_type_t event_type, unidata_t   unidata )
{
    if( event_type == GIOP_INTERRUPT ) {
        /* Изменилось состояние входов */
#if defined(BLINK_ON)
        port_t  ledpin;
        port_read( LED_PORT, LED1, &ledpin );
        ledpin ^= LED1; 
        port_write( LED_PORT, LED1, ledpin );
#endif
#if defined(INVERT_ATTR)
        unidata = ~unidata;
#endif        
        attr_write( INPUT, &unidata );
    } else if( event_type == EV_AWRITTEN ){
        if( unidata == OUTPUT ) {
            /* Изменён атрибут цифровых выходов */
            port_t  out;
            result_t res = attr_read( OUTPUT, &out );
            if( IS_OK(res) ) {
                /* Записываем в порт новое значение атрибута */
                port_write( OPORT, OPINS, out );
            }
#if defined(BLINK_ON)
            port_t  ledpin;
            port_read( LED_PORT, LED2, &ledpin );
            ledpin ^= LED2; 
            port_write( LED_PORT, LED2, ledpin );
#endif
        }
    }
    return;
}
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:33,代码来源:giop.c


示例4: main

void main(){

// Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		// action a0
		int D0, D1;

		D0 = port_read(&X);
		D1 = port_read(&X);
		// end of a0

		// action a1
		int d2, d3;

		d2 = port_read(&X);
		d3 = port_read(&X);

#if 1
		port_write(&Y, D0 + d2); i++;
		port_write(&Y, D0 - d2); i++;
		port_write(&Y, D1 + d3); i++;
		port_write(&Y, D1 - d3); i++;
		// end of a1
#endif

#if 0
		Mailbox.pOutputBuffer[i] = D0 + d2; i++;
		Mailbox.pOutputBuffer[i] = D0 - d2; i++;
		Mailbox.pOutputBuffer[i] = D1 + d3; i++;
		Mailbox.pOutputBuffer[i] = D1 - d3; i++;
#endif
	}
#if 0
*Mailbox.pOutputReady = 10;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
开发者ID:njpacoma,项目名称:parallella-examples,代码行数:59,代码来源:shuffleFlyCol.c


示例5: main

void main(){

  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_CLK, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;

	// wait for the go (which means actors are connected)
	while(Mailbox.pGo[me.corenum] == 0);

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_CLK, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);

	while(i < IN_BUFFER_SIZE)
	{
		// action a0
		int a, b, c, d;
	
		a = port_read(&X);
		b = port_read(&X);
		c = port_read(&X);
		d = port_read(&X);

#if 1
		port_write(&Y, (a + c) >> 8); i++;
		port_write(&Y, (a - c) >> 8); i++;
		port_write(&Y, (b + d) >> 8); i++;
		port_write(&Y, (b - d) >> 8); i++;
		// end of action a0
#endif

#if 0
		Mailbox.pOutputBuffer[i] = (a + c) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (a - c) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (b + d) >> 8; i++;
		Mailbox.pOutputBuffer[i] = (b - d) >> 8; i++;
#endif

	}

#if 0
*Mailbox.pOutputReady = 12;
#endif

// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
开发者ID:9578577,项目名称:parallella-examples,代码行数:57,代码来源:finalCol.c


示例6: main

void main()
{
  // Configure the timers
 e_ctimer_set(E_CTIMER_0, E_CTIMER_MAX); 

 // Start the timer (countdown from 0xFFFFFFFF)
 e_ctimer_start(E_CTIMER_0, E_CTIMER_CLK);

	init();
	int i = 0;
	int a, b;
	int w0, w1;

	// Wait until we get the go message from the host
	while(Mailbox.pGo[me.corenum] == 0); 

timerValue = e_ctimer_get(E_CTIMER_0);
Mailbox.pTimer0[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_0);

e_ctimer_set(E_CTIMER_1, E_CTIMER_MAX); 
e_ctimer_start(E_CTIMER_1, E_CTIMER_CLK);
	// Run continuously
	while(i < (IN_BUFFER_SIZE * 2))//temporary value 128
	{
	  w0 = ww0;
	  w1 = ww1;
		index0 = (index0 + 1) & 3;

		ww0 = W0[index0];
		ww1 = W1[index0];

		a = port_read(&X);
		b = port_read(&X);

// For full version we need to change the following line to #ifdef FULL
#if 1
		port_write(&Y, a * w0); i++;
		port_write(&Y, a * w1); i++;
		port_write(&Y, b * w0); i++;
		port_write(&Y, b * w1); i++;
#endif

#if 0
		// Send the outputs to the host
		Mailbox.pOutputBuffer[i] = a * w0; i++;
		Mailbox.pOutputBuffer[i] = a * w1; i++;
		Mailbox.pOutputBuffer[i] = b * w0; i++;
		Mailbox.pOutputBuffer[i] = b * w1; i++;
#endif
	}
	
// Get timer value, find the elapsed time and stop 
timerValue = e_ctimer_get(E_CTIMER_1);
Mailbox.pTimer1[me.corenum] = E_CTIMER_MAX - timerValue;
e_ctimer_stop(E_CTIMER_1);
}
开发者ID:njpacoma,项目名称:parallella-examples,代码行数:57,代码来源:scale.c


示例7: mmcPower

unsigned char mmcPower(unsigned char cmd)
{
#ifndef PORT_WRITE
   switch(cmd)
   {
   case MMC_ON:
      MMC_PWR_POUT &= ~MMC_CARD_PWR;
      break;
   case MMC_OFF:
      MMC_PWR_POUT |=  MMC_CARD_PWR;
      break;
//   default:
//      return MMC_PWR_PORT;
   }
   return MMC_PWR_POUT;
#else  // !PORT_WRITE
   unsigned char pval;
   switch(cmd)
   {
   case MMC_ON:
      port_write(MMC_PWR_PORT, MMC_CARD_PWR, PIN_LO);
      break;
   case MMC_OFF:
      port_write(MMC_PWR_PORT, MMC_CARD_PWR, PIN_HI);
      break;
//   default:
//      return MMC_PWR_PORT;
   }
   port_read(MMC_PWR_PORT, MMC_CARD_PWR, &pval);
   return pval;
#endif // !PORT_WRITE
}
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:32,代码来源:mmc.c


示例8: read_hd_sector

/*
 *static int read_hd_sector(void *hd_buff , int driver , unsigned int abs_sec)
 * 读硬盘一个扇区的信息。driver表示选中的硬盘。sec表示扇区号(绝对扇区号)
 * 成功返回0否则返回-1
 */
static int read_hd_sector(void *hd_buff , int driver , unsigned int abs_sec){
	HD_CMD cmd;
	int result;

	cmd.feature = 0;
	cmd.sec_counter = 1;
	cmd.lba_low = (abs_sec) & 0xFF;	//因为使用的是LBA模式。所以只需要输入绝对扇区号。注意DEVICE最低四位是扇区号最高四位
	cmd.lba_mid = (abs_sec >> 8) & 0xFF;
	cmd.lba_hig = (abs_sec >> 16) & 0xFF;
	cmd.device = SET_REG_DEVICE(1 , driver , (abs_sec) >> 24);	//SET_REG_DEVICE(LBA , DRV , LBA_HIGHEST)
	cmd.command = ATA_READ;

	result = send_hd_cmd(&cmd);


	if(result == 0){
		wait(SIG_READY);
		port_read(hd_buff , SEC_SIZE / 4 , REG_DATA);
		return 0;
	}else{
		printf("Read Error!");	//失败将显示信息。成功则不显示信息
		return -1;
	}

}	//end function
开发者ID:nmsoccer,项目名称:micro_kernel,代码行数:30,代码来源:hd.c


示例9: hd_identify

/*
功能:
    获取硬盘信息。主要是获取对应硬盘的容量,获取的信息保存在hd_info中
参数:
    device:系统统一设备编号
返回值:
    (无)
*/
static void hd_identify(int index){
    int hd_index=HD_INDEX(index);

    struct s_hd_command cmd;
    cmd.device=MAKE_DEVICE_REG(0,hd_index,0);
    cmd.command=ATA_IDENTIFY;
    hd_command_out(&cmd);

#ifdef DEBUG_HD
    printl("interrupt_wait\n");
#endif

    interrupt_wait();

    port_read(REG_P_DATA,hdbuf,SECTOR_SIZE);

#ifdef DEBUG_HD
    print_identify_info((u16*)hdbuf); 
#endif
    
    u16 *hdinfo=(u16*)hdbuf;
    //硬盘基址 
    hd_info[hd_index].primary[0].base=0;
    //硬盘扇区数
    hd_info[hd_index].primary[0].size=((int)hdinfo[61]<<16)+hdinfo[60];
}
开发者ID:565407548,项目名称:micro_os,代码行数:34,代码来源:hd.c


示例10: hd_identify

/*
 * static int hd_identify(int driver);
 * 获取硬盘的信息。硬盘号由driver给出。
 */
static int hd_identify(int driver){
	HD_CMD cmd;
	u8 status;
	char hdbuf[SEC_SIZE];

	cmd.feature = 0;
	cmd.sec_counter = 0;
	cmd.lba_low = 0;
	cmd.lba_mid = 0;
	cmd.lba_hig = 0;
	cmd.device  = SET_REG_DEVICE(0, driver, 0);
	cmd.command = ATA_IDENTIFY;


	send_hd_cmd(&cmd);


	wait(SIG_READY);

	port_read(hdbuf , SEC_SIZE/4 , (u32)REG_DATA);	//因为port_read一次读入insd四字节

//	print_identify_info((u16*)hdbuf);

	return 0;

}
开发者ID:nmsoccer,项目名称:micro_kernel,代码行数:30,代码来源:hd.c


示例11: hd_rdwt

/**
 * <Ring 1> This routine handles DEV_READ and DEV_WRITE message.
 *
 * @param p Message ptr.
 *****************************************************************************/
PRIVATE void hd_rdwt(MESSAGE * p)
{
    // p->DEVICE 為 0x20,也就是 hd2a
    int pDev = p->DEVICE;
    int drive = DRV_OF_DEV(p->DEVICE);
    u64 pos = p->POSITION;
    assert((pos >> SECTOR_SIZE_SHIFT) < (1 << 31));

    /**
     * We only allow to R/W from a SECTOR boundary:
     */
    assert((pos & 0x1FF) == 0);

    u32 sect_nr = (u32)(pos >> SECTOR_SIZE_SHIFT); /* pos / SECTOR_SIZE */

    //取出logic index
    int logidx = (p->DEVICE - MINOR_hd1a) % NR_SUB_PER_DRIVE;

    // 找出某個partition的LBA,
    // MAX_PRIM=9,代表Hd0~Hd9為primary的編號,超過9以上的編號都是logic
    sect_nr += p->DEVICE < MAX_PRIM ?
               hd_info[drive].primary[p->DEVICE].base :
               hd_info[drive].logical[logidx].base;

    ERIC_HD("\nHDRW=%x", sect_nr);

    struct hd_cmd cmd;
    cmd.features	= 0;
    cmd.count	= (p->CNT + SECTOR_SIZE - 1) / SECTOR_SIZE;
    cmd.lba_low	= sect_nr & 0xFF;
    cmd.lba_mid	= (sect_nr >>  8) & 0xFF;
    cmd.lba_high= (sect_nr >> 16) & 0xFF;
    cmd.device	= MAKE_DEVICE_REG(1, drive, (sect_nr >> 24) & 0xF);
    cmd.command	= (p->type == DEV_READ) ? ATA_READ : ATA_WRITE;

    hd_cmd_out(&cmd);

    int bytes_left = p->CNT;
    void * la = (void*)va2la(p->PROC_NR, p->BUF);

    while (bytes_left) {
        //一次只讀512 byte
        int bytes = min(SECTOR_SIZE, bytes_left);

        if (p->type == DEV_READ) {
            interrupt_wait();
            port_read(REG_DATA, hdbuf, SECTOR_SIZE);
            phys_copy(la, (void*)va2la(TASK_HD, hdbuf), bytes);
        }
        else {
            if (!waitfor(STATUS_DRQ, STATUS_DRQ, HD_TIMEOUT))
                panic("hd writing error.");

            port_write(REG_DATA, la, bytes);
            interrupt_wait();
        }
        bytes_left -= SECTOR_SIZE;
        la += SECTOR_SIZE;
    }
}
开发者ID:wwssllabcd,项目名称:myOS,代码行数:65,代码来源:hd.c


示例12: line_get

static inline int line_get(const struct lineop *op)
{
	u8 oldval = port_read(op->port);

	return ((op->inverted && (oldval & op->val) != op->val)
	    || (!op->inverted && (oldval & op->val) == op->val));
}
开发者ID:12019,项目名称:kernel_zte_u880,代码行数:7,代码来源:i2c-parport-light.c


示例13: toggleLED

void toggleLED(unsigned int leds)
{
   port_t LEDport;
   port_read(LED_PORT, leds, &LEDport);
   LEDport ^= (unsigned char)leds;
   port_write(LED_PORT, (unsigned char)leds &   LEDport,  PIN_HI);
   port_write(LED_PORT, (unsigned char)leds & (~LEDport), PIN_LO);
}
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:8,代码来源:oled_app.c


示例14: port_read_byte

uint8_t port_read_byte(uint16_t address) {
#ifdef DEBUG_SUPPORT
    if (debugger.data.ports[address] & DBG_PORT_READ) {
        open_debugger(HIT_PORT_READ_BREAKPOINT, address);
    }
#endif
    return port_read(address, false);
}
开发者ID:alberthdev,项目名称:CEmu,代码行数:8,代码来源:port.c


示例15: lcd1602_busy

//读状态
u8 lcd1602_busy(void)
{
	u8 result;
        port_write(0xff);
	RS_CLR;
	RW_SET;
        EN_CLR;
        EN_CLR;
	EN_SET;
        asm("nop");
     //   asm("nop");
	//delay_ms(5);
	port_in();

	while(port_read() & 0x80);
	//EN_CLR;
	return port_read();
}
开发者ID:xinshaochen,项目名称:Space,代码行数:19,代码来源:1602.c


示例16: SPC_COMMAND

static void SPC_COMMAND( uint8_t cmd, uint8_t param1, uint8_t param2 ) {
	while( port_read(PORT_SPC1) != SPC_V ) {}
	port_write( PORT_SPC0, cmd );
	port_write( PORT_SPC2, param1 );
	port_write( PORT_SPC3, param2 );

	SPC_V ^= 0x80;
	port_write( PORT_SPC1, SPC_V );
}
开发者ID:mRB0,项目名称:nintendont,代码行数:9,代码来源:spcunit.c


示例17: SPCU_TRANSFER

void SPCU_TRANSFER( uint16_t DATA, uint8_t FINAL ) {
	while( port_read( PORT_SPC1 ) != SPC_V ) {}
	port_write( PORT_SPC2, DATA & 0xFF );
	port_write( PORT_SPC3, DATA >> 8 );
	if( FINAL )
		SPC_V = 0;
	else
		SPC_V ^= 0x80;
	port_write( PORT_SPC1, SPC_V );
}
开发者ID:mRB0,项目名称:nintendont,代码行数:10,代码来源:spcunit.c


示例18: lcd1602_read_data

//读数据
u8 lcd1602_read_data(void)
{
  RS_SET;
  RW_SET;
  EN_CLR;
  EN_CLR;
  EN_SET;
  port_in();
  return port_read();
}
开发者ID:xinshaochen,项目名称:Space,代码行数:11,代码来源:1602.c


示例19: line_set

static inline void line_set(int state, const struct lineop *op)
{
	u8 oldval = port_read(op->port);

	/* Touch only the bit(s) needed */
	if ((op->inverted && !state) || (!op->inverted && state))
		port_write(op->port, oldval | op->val);
	else
		port_write(op->port, oldval & ~op->val);
}
开发者ID:12019,项目名称:kernel_zte_u880,代码行数:10,代码来源:i2c-parport-light.c


示例20: hd_identify

/**
 * <Ring 1> Get the disk information.
 * 
 * @param drive  Drive Nr.
 *****************************************************************************/
PRIVATE void hd_identify(int drive)
{
	struct hd_cmd cmd;
	cmd.device  = MAKE_DEVICE_REG(0, drive, 0);
	cmd.command = ATA_IDENTIFY;
	hd_cmd_out(&cmd);
	interrupt_wait();
	port_read(REG_DATA, hdbuf, SECTOR_SIZE);

	print_identify_info((u16*)hdbuf);
}
开发者ID:gtxx3600,项目名称:mySimpleOS,代码行数:16,代码来源:hd.c



注:本文中的port_read函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ port_to_dev函数代码示例发布时间:2022-05-30
下一篇:
C++ port_pin_set_output_level函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap