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

C++ CS_HIGH函数代码示例

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

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



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

示例1: SD_WriteOneSector

BYTE SD_WriteOneSector(DWORD sector,BYTE* buf){//写一个扇区(buf为512字节),成功返回0
	BYTE rtn;
	WORD i,cnt=0;
	SPI_SetSpeedHigh();//设定SPI到高速模式
	rtn=SD_SendCommand(24,sector<<9);//读命令
	if(rtn!=0x00)
		return rtn;
	CS_LOW();
	SPI_ByteRW(0xFF);
	SPI_ByteRW(0xFF);
	SPI_ByteRW(0xFF);
	SPI_ByteRW(0xFE);//发开始符
	for(i=0;i<512;i++){//送512字节数据
		SPI_ByteRW(*(buf++));
	}	
	SPI_ByteRW(0xFF);//dummy crc
	SPI_ByteRW(0xFF);
	rtn=SPI_ByteRW(0xFF);
	
	if((rtn & 0x1F)!=0x05){//等待是否成功
		CS_HIGH();
		return rtn;
	}
	//等待操作完
	while(!SPI_ByteRW(0xFF)){
		if((cnt++)==0xFFFF){
			CS_HIGH();
			return 1;//超时退出
		}
	}
	CS_HIGH();
	SPI_ByteRW(0xFF);//额外8个时钟周期
	return 0;
}
开发者ID:gnimnet,项目名称:libm64,代码行数:34,代码来源:MMC_SD.c


示例2: mmc_GoIdle

unsigned char mmc_GoIdle()
{
  unsigned char response=0x01;
  CS_LOW();

  //Send Command 0 to put MMC in SPI mode
  mmcSendCmd(MMC_GO_IDLE_STATE,0,0x95);
  //Now wait for READY RESPONSE
  if((mmc_error = mmcGetResponse())!=0x01)
  {
    CS_HIGH();
    return MMC_INIT_ERROR;
  }

  while(response==0x01)
  {
    CS_HIGH();
    spiSendByte(0xff);
    CS_LOW();
    mmcSendCmd(MMC_SEND_OP_COND,0x00,0xff);
    response=mmcGetResponse();
  }
  CS_HIGH();
  spiSendByte(0xff);
  return MMC_SUCCESS;
}
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:26,代码来源:mmc.c


示例3: mmcReadRegister

// Reading the contents of the CSD and CID registers in SPI mode is a simple
// read-block transaction.
unsigned char mmcReadRegister (const char cmd_register, const unsigned char length, unsigned char *pBuffer)
{
  unsigned char uc = 0;
  unsigned char rvalue = MMC_TIMEOUT_ERROR;

  if (mmcSetBlockLength (length) == MMC_SUCCESS)
  {
    CS_LOW ();
    // CRC not used: 0xff as last byte
    mmcSendCmd(cmd_register, 0x000000, 0xff);

    // wait for response
    // in the R1 format (0x00 is no errors)
    if (mmcGetResponse() == 0x00)
    {
      if (mmcGetXXResponse(0xfe)== 0xfe)
        for (uc = 0; uc < length; uc++)
          pBuffer[uc] = spiSendByte(0xff);  //mmc_buffer[uc] = spiSendByte(0xff);
      // get CRC bytes (not really needed by us, but required by MMC)
      spiSendByte(0xff);
      spiSendByte(0xff);
      rvalue = MMC_SUCCESS;
    }
    else
      rvalue = MMC_RESPONSE_ERROR;
    // CS = HIGH (off)
    CS_HIGH ();

    // Send 8 Clock pulses of delay.
    spiSendByte(0xff);
  }
  CS_HIGH ();
  return rvalue;
} // mmc_read_register
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:36,代码来源:mmc.c


示例4: initMMC

// 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());
}
开发者ID:MaxGekk,项目名称:ZigZag,代码行数:60,代码来源:mmc.c


示例5: nrf_snd_pkt_crc_encr

char nrf_snd_pkt_crc_encr(int size, uint8_t * pkt, uint32_t const key[4]){

    if(size > MAX_PKT)
        size=MAX_PKT;

    nrf_write_reg(R_CONFIG,
            R_CONFIG_PWR_UP|  // Power on
            R_CONFIG_EN_CRC   // CRC on, single byte
            );
    
//    nrf_write_long(C_W_TX_PAYLOAD,size,pkt);
    uint16_t crc=crc16(pkt,size-2);
    pkt[size-2]=(crc >>8) & 0xff;
    pkt[size-1]=crc & 0xff;
    if(key !=NULL)
        xxtea_encode_words((uint32_t*)pkt,size/4,key);

    CS_LOW();
    xmit_spi(C_W_TX_PAYLOAD);
    sspSend(0,pkt,size);
    CS_HIGH();

    CE_HIGH();
    delayms(1); // Send it.  (only needs >10ys, i think)
    CE_LOW();

    return nrf_cmd_status(C_NOP);
};
开发者ID:DanBUK,项目名称:r0ket,代码行数:28,代码来源:nrf24l01p.c


示例6: nrf_read_pkt_crc

void nrf_read_pkt_crc(int len, uint8_t* data, uint8_t* crc){
    CS_LOW();
    xmit_spi(C_R_RX_PAYLOAD);
    sspReceive(0,data,len);
    sspReceive(0,crc,2);
    CS_HIGH();
};
开发者ID:DanBUK,项目名称:r0ket,代码行数:7,代码来源:nrf24l01p.c


示例7: sd_write

void sd_write(char __flash *str, unsigned long int bpos) {
  CS_LOW();
  
  spi_sendbyte(0xFF);
  
  //converting bpos to 4 bytes and set write-start position
  spi_sendbyte(0x58);
  spi_sendbyte(((bpos & 0xFF000000)>>24));
  spi_sendbyte(((bpos & 0x00FF0000)>>16)); 
  spi_sendbyte(((bpos & 0x0000FF00)>>8));
  spi_sendbyte(((bpos & 0x000000FF)));
  spi_sendbyte(0x00); //CRC
 
  while (spi_sendbyte(0xFF)!=0x0);
  
  spi_sendbyte(0xFF); 
  spi_sendbyte(0xFE); 
  _spi_sendtext(str); //str len up to 512 bytes
  spi_sendbyte(0x00); //1-st byte CRC
  spi_sendbyte(0x00); //2-nd byte CRC
  
  while (spi_sendbyte(0xFF)&0x5 != 0x5); //waiting for the command reception signal

  while (spi_sendbyte(0xFF)!=0x00); //waiting for the command reception signal
  
  test(2);
  
  CS_HIGH();
  
}
开发者ID:DySprozin,项目名称:avr,代码行数:30,代码来源:SD_USI.c


示例8: SD_read

// TODO: This function will not exit gracefully if SD card does not do what it should
void SD_read(unsigned long sector, unsigned short offset, unsigned char * buffer, 
             unsigned short len) {
    unsigned short i, pos = 0;
    
    CS_LOW();
    SPI_send(0x51);       // sector * 512 = sector << 9 
    SPI_send(sector>>15); // sector*512 >> 24  
    SPI_send(sector>>7);  // sector*512 >> 16
    SPI_send(sector<<1);  // sector*512 >> 8
    SPI_send(0);          // sector*512
    SPI_send(0xFF);
    
    for(i=0; i<10 && SPI_send(0xFF) != 0x00; i++) {} // wait for 0
    
    for(i=0; i<10 && SPI_send(0xFF) != 0xFE; i++) {} // wait for data start
    
    for(i=0; i<offset; i++) // "skip" bytes
        SPI_send(0xFF);
        
    for(i=0; i<len; i++) // read len bytes
        buffer[i] = SPI_send(0xFF);
        
    for(i+=offset; i<512; i++) // "skip" again
        SPI_send(0xFF);
        
    // skip checksum
    SPI_send(0xFF);
    SPI_send(0xFF);    

    CS_HIGH();    
}
开发者ID:robwasab,项目名称:CableRelease,代码行数:32,代码来源:SD.c


示例9: nrf_cmd_status

uint8_t nrf_cmd_status(uint8_t cmd)
{
	CS_LOW();
	sspSendReceive(&cmd, 1);
	CS_HIGH();
	return cmd;
};
开发者ID:sebseb7,项目名称:g3d2,代码行数:7,代码来源:nrf24l01p.c


示例10: nrf_read_pkt

void nrf_read_pkt(int len, uint8_t* data)
{
	CS_LOW();
	sspSendByte(C_R_RX_PAYLOAD);
	sspReceive(data,len);
	CS_HIGH();
};
开发者ID:sebseb7,项目名称:g3d2,代码行数:7,代码来源:nrf24l01p.c


示例11: max1168_read_adc

uint16_t max1168_read_adc(uint8_t reg, enum max1168_clk clk, enum max1168_mode mode)
{
    #define CH2 0x20
    uint16_t raw_data;
    max1168_init();

    if (mode == MODE_8BIT)
        PORTB &= ~(1<<DSEL);
    else
        PORTB |= (1<<DSEL);

    CS_LOW();
    /* TODO: remove hardcoded channel */
    max1168_xfer_byte(CH2 | clk);

    if (mode == MODE_16BIT)
        max1168_xfer_byte(SPI_DUMMY_BYTE);

    if (clk == CLK_INTERNAL)
        while ((PINB & (1<<EOC)));

    raw_data = max1168_xfer_byte(SPI_DUMMY_BYTE) << 8;
    raw_data |= max1168_xfer_byte(SPI_DUMMY_BYTE);
    CS_HIGH();

    return raw_data;
}
开发者ID:pkadev,项目名称:max1168,代码行数:27,代码来源:max1168.c


示例12: irq_callback

STATIC mp_obj_t irq_callback(mp_obj_t line)
{
    DEBUG_printf("<< IRQ; state=%lu >>\n", sSpiInformation.ulSpiState);
    switch (sSpiInformation.ulSpiState) {
        case eSPI_STATE_POWERUP:
            /* This means IRQ line was low call a callback of HCI Layer to inform on event */
            DEBUG_printf(" - POWERUP\n");
            sSpiInformation.ulSpiState = eSPI_STATE_INITIALIZED;
            break;
        case eSPI_STATE_IDLE:
            DEBUG_printf(" - IDLE\n");
            sSpiInformation.ulSpiState = eSPI_STATE_READ_IRQ;

            /* IRQ line goes down - we are start reception */
            CS_LOW();

            // Wait for TX/RX Compete which will come as DMA interrupt
            SpiReadHeader();

            sSpiInformation.ulSpiState = eSPI_STATE_READ_EOT;

            SSIContReadOperation();
            break;
        case eSPI_STATE_WRITE_IRQ:
            DEBUG_printf(" - WRITE IRQ\n");
            SpiWriteDataSynchronous(sSpiInformation.pTxPacket, sSpiInformation.usTxPacketLength);

            sSpiInformation.ulSpiState = eSPI_STATE_IDLE;

            CS_HIGH();
            break;
    }
    return mp_const_none;
}
开发者ID:andrecurvello,项目名称:micropython,代码行数:34,代码来源:ccspi.c


示例13: dataflash_random_read

DRESULT dataflash_random_read(BYTE *buff, DWORD offset, DWORD length) {
    if (!length) return RES_PARERR;
    if (status & STA_NOINIT) return RES_NOTRDY;
    if (offset+length > MAX_PAGE*256) return RES_PARERR;

    do {
        wait_for_ready();
        DWORD pageaddr = ((offset/256) << 9) | (offset%256);
        DWORD remaining = 256 - offset%256;
        if (remaining > length) {
            remaining = length;
        }
        length -= remaining;
        offset += remaining;

        CS_LOW();
        xmit_spi(OP_PAGEREAD);
        xmit_spi((BYTE)(pageaddr >> 16));
        xmit_spi((BYTE)(pageaddr >> 8));
        xmit_spi((BYTE)pageaddr);
        xmit_spi(0x00); // follow up with 4 don't care bytes
        xmit_spi(0x00);
        xmit_spi(0x00);
        xmit_spi(0x00);
        do {
            rcvr_spi_m(buff++);
        } while (--remaining);
        CS_HIGH();
    } while (length);

    return length ? RES_ERROR : RES_OK;
}
开发者ID:pyropeter,项目名称:hackoverbadge-firmware,代码行数:32,代码来源:at45db041d.c


示例14: fm25_hw_init

void fm25_hw_init()
{
	int i = 0xFFFFF;
	fm25_spi_cfg();

	while(i--);
	//spi_config();
	CS_LOW();
    spi_readwrite( FM25_WRDI );
    CS_HIGH();

	spi_flash_device.type    = RT_Device_Class_Block;
    spi_flash_device.init    = fm25_init;
    spi_flash_device.open    = fm25_open;
    spi_flash_device.close   = fm25_close;
    spi_flash_device.read 	 = fm25_read;
    spi_flash_device.write   = fm25_write;
    spi_flash_device.control = fm25_control;
    /* no private */
    spi_flash_device.user_data = RT_NULL;

    rt_device_register(&spi_flash_device, "fram0",
                       RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);

}
开发者ID:304471720,项目名称:rt-thread,代码行数:25,代码来源:FM25Lx.c


示例15: fm25_read

rt_size_t fm25_read(rt_device_t dev, rt_off_t offset, void * buf, rt_size_t size)
{
    uint32_t index;

	uint8_t *buffer = (uint8_t*) buf;

    fram_lock();
    //spi_config();
	//rt_kprintf("READ: %d, size=%d\n", offset, size);

    CS_LOW();
	spi_readwrite( FM25_READ);
	spi_readwrite( (offset >> 8)&0xFF );
	spi_readwrite( offset & 0xFF  );
    for(index=0; index<size; index++)
    {
		*buffer++ = spi_readwrite(0xFF);

		if( spi_timeout_cnt > 0 )
		{
			fram_unlock();
			spi_timeout_cnt = 0;
			rt_kprintf("Read time out\n");
			return -1;
		}

		offset++;
    }
    CS_HIGH();

    fram_unlock();

    return size;
}
开发者ID:304471720,项目名称:rt-thread,代码行数:34,代码来源:FM25Lx.c


示例16: nrf_write_reg

void nrf_write_reg(const uint8_t reg, const uint8_t val)
{
	CS_LOW();
	sspSendByte(C_W_REGISTER | reg);
	sspSendByte(val);
	CS_HIGH();
};
开发者ID:sebseb7,项目名称:g3d2,代码行数:7,代码来源:nrf24l01p.c


示例17: finit3310

void finit3310( void )
{
    CS_HIGH();
    RST_HIGH();
    DC_HIGH();
    delay3310( 100000 );
}
开发者ID:z80,项目名称:clock,代码行数:7,代码来源:3310-backend.c


示例18: nrf_write_long

void nrf_write_long(const uint8_t cmd, int len, const uint8_t* data)
{
	CS_LOW();
	sspSendByte(cmd);
	sspSend(data,len);
	CS_HIGH();
};
开发者ID:sebseb7,项目名称:g3d2,代码行数:7,代码来源:nrf24l01p.c


示例19: SD_initialize

char SD_initialize(void) {
    char i;
    cli();
    // ]r:10
    CS_HIGH();
    for(i=0; i<10; i++) // idle for 1 bytes / 80 clocks
        SPI_send(0xFF);
                
    // [0x40 0x00 0x00 0x00 0x00 0x95 r:8] until we get "1"
    for(i=0; i<10 && SD_command(0x40, 0x00000000, 0x95, 8) != 1; i++) {
       delay_ms(100);
    }
    if(i == 10) // card did not respond to initialization
        return CARD_NOT_INIT;
                
    // CMD1 until card comes out of idle, but maximum of 10 times
    for(i=0; i<10 && SD_command(0x41, 0x00000000, 0xFF, 8) != 0; i++) {
       delay_ms(100);
    }

    if(i == 10) // card did not come out of idle
        return CARD_IN_IDLE;
                
    // SET_BLOCKLEN to 512
    SD_command(0x50, 0x00000200, 0xFF, 8);
        
    sd_sector = sd_pos = 0;
        
    return CARD_INIT;
}
开发者ID:robwasab,项目名称:CableRelease,代码行数:30,代码来源:SD.c


示例20: mmcMountBlock

char mmcMountBlock(unsigned long address)
{
  char rvalue = MMC_RESPONSE_ERROR;
  
  // Set the block length to read
  if (mmcSetBlockLength (512) == MMC_SUCCESS)   // block length could be set
  {
    // SS = LOW (on)
    CS_LOW ();
    // send read command MMC_READ_SINGLE_BLOCK=CMD17
    mmcSendCmd (MMC_READ_SINGLE_BLOCK, address, 0xFF);
    // Send 8 Clock pulses of delay, check if the MMC acknowledged the read block command
    // it will do this by sending an affirmative response
    // in the R1 format (0x00 is no errors)
    if (mmcGetResponse() == 0x00)
    {
      // now look for the data token to signify the start of
      // the data
      if (mmcGetXXResponse(MMC_START_DATA_BLOCK_TOKEN) == MMC_START_DATA_BLOCK_TOKEN)
      {
         //success, data ready to read
         rvalue = MMC_SUCCESS;
      }
      else
      {
        // the data token was never received
        rvalue = MMC_DATA_TOKEN_ERROR;      // 3
        CS_HIGH ();
        spiSendByte(0xff);
      }
    }
    else
    {
      // the MMC never acknowledge the read command
      rvalue = MMC_RESPONSE_ERROR;          // 2
      CS_HIGH ();
      spiSendByte(0xff);
    }
  }
  else
  {
    rvalue = MMC_BLOCK_SET_ERROR;           // 1
    CS_HIGH ();
    spiSendByte(0xff);
  }
    return rvalue;
}// mmc_read_block
开发者ID:lunakid,项目名称:msp-exp,代码行数:47,代码来源:mmc.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ CS_LOCALS函数代码示例发布时间:2022-05-30
下一篇:
C++ CS_GetEntryCount函数代码示例发布时间: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