当前位置: 首页>>代码示例>>C++>>正文


C++ SPI_FLASH_CS_HIGH函数代码示例

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


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

示例1: SFlash_Read_ID

/*********************************************************************//**
 * @author             
 * @brief 	
 * @date 
 * @version  
 * @description 
 * @param[in]		None.
 * @param[out]		None.
 * @return 				             
 *                         
 **********************************************************************/
uint32_t SFlash_Read_ID(IDtype_t IDType)
{
	uint32_t temp = 0;
              
	if (IDType == JEDEC_ID)
	{
		SPI_FLASH_CS_LOW();	
				
		Flash_ReadWriteByte(0x9F);		 		         /* Send read JEDEC ID command (9Fh) */
    	        
    temp = (temp | Flash_ReadWriteByte(0x00)) << 8;  /* Receive Data */
		temp = (temp | Flash_ReadWriteByte(0x00)) << 8;	
    temp = (temp | Flash_ReadWriteByte(0x00)); 	     /* temp value is 0xBF2541 */

    SPI_FLASH_CS_HIGH();
		return temp;
	}
	
	if ((IDType == Manufacturer_ID) || (IDType == Device_ID) )
	{
		
	  SPI_FLASH_CS_LOW();				
		Flash_ReadWriteByte(0x90);				/* Send read ID command (90h or ABh) */
    Flash_ReadWriteByte(0x00);				/* Send address	*/
		Flash_ReadWriteByte(0x00);				/* Send address	*/
		Flash_ReadWriteByte(0x00);		    /* Send address - 00H or 01H */
		temp = Flash_ReadWriteByte(0x00)<<8;	    /* Receive Data */
		temp |= Flash_ReadWriteByte(0x00);	
		//delay_ms(1);	//if datarate less than 3000000hz add delay for cheap select	
    SPI_FLASH_CS_HIGH();
		return temp;
	}
	return FALSE;	

}
开发者ID:saeedhadi,项目名称:Metering,代码行数:46,代码来源:FlashRTC.c

示例2: spi_flash_wait_for_write_end

/**
* @brief  Polls the status of the Write In Progress (WIP) flag in the
*   FLASH's status  register  and  loop  until write  opertaion
*   has completed.
* @param  None
* @retval 0: 成功
*        -1: 超时
*/
int spi_flash_wait_for_write_end(void)
{
	OS_CPU_SR  cpu_sr = 0;
	unsigned char FLASH_Status = 0;
	volatile unsigned int i = 0;
	/* Select the FLASH: Chip Select low */
	SPI_FLASH_CS_LOW();

	/* Send "Read Status Register" instruction */
	spi_flash_send_byte(RDSR);

	/* Loop as long as the memory is busy with a write cycle */
	do
	{
		/* Send a dummy byte to generate the clock needed by the FLASH
		and put the value of the status register in FLASH_Status variable */
		FLASH_Status = spi_flash_send_byte(Dummy_Byte);
		i++;
		if (i > 0xFFFFFFFE)	//测试超时
		{
			/* Deselect the FLASH: Chip Select high */
			SPI_FLASH_CS_HIGH();
			OS_EXIT_CRITICAL();
			return -1;
		}
	}
	while ((FLASH_Status & WIP_Flag) == SET); /* Write in progress */

	/* Deselect the FLASH: Chip Select high */
	SPI_FLASH_CS_HIGH();
	//spi_flash_busy_flag = 0;
	OS_EXIT_CRITICAL();
	return 0;
}
开发者ID:joe3501,项目名称:BlueRing,代码行数:42,代码来源:spi_flash.c

示例3: SFlash_Write_AAI_All

/*********************************************************************//**
 * @author             
 * @brief 	
 * @date 
 * @version  
 * @description 
 * @param[in]		None.
 * @param[out]		None.
 * @return 				             
 *                         
 **********************************************************************/
void SFlash_Write_AAI_All(uint8_t data[], uint8_t len, uint32_t address)
{
	uint32_t i;
	SFlash_Write_Status_Rregister(0x00);
	SFlash_Write_Enable();
	
	SPI_FLASH_CS_LOW();					
	Flash_ReadWriteByte(PROGRAM_AAI_OPCODE);
	Flash_ReadWriteByte(address >> 16);
	Flash_ReadWriteByte(address >> 8);
	Flash_ReadWriteByte(address);
	Flash_ReadWriteByte(data[0]);
	Flash_ReadWriteByte(data[1]);
	SPI_FLASH_CS_HIGH();
	//delay_ms(1);
	WaitBusy();
	//while (SFlash_Read_Status_Register() & 0x01);
	//while (Flash_ReadWriteByte(RDSR_OPCODE) & 0x01);/* Send Read Status Register command */
	//len = len-2;
	for (i = 2; i<len; i+=2)
	{
		SPI_FLASH_CS_LOW();
		Flash_ReadWriteByte(PROGRAM_AAI_OPCODE);
		Flash_ReadWriteByte(data[i]);
		Flash_ReadWriteByte(data[i+1]);	
		SPI_FLASH_CS_HIGH();
		//delay_ms(1);
		//while (SFlash_Read_Status_Register() & 0x01);
		//while (Flash_ReadWriteByte(RDSR_OPCODE) & 0x01);/* Send Read Status Register command */
		WaitBusy();
	}	
	
}
开发者ID:saeedhadi,项目名称:Metering,代码行数:44,代码来源:FlashRTC.c

示例4: spi_flash_raddr

/**
* @brief  Reads a block of data from the FLASH.
* @param pBuffer : pointer to the buffer that receives the data read
*                  from the FLASH.
* @param ReadAddr : FLASH's internal address to read from.
* @param NumByteToRead : number of bytes to read from the FLASH.
* @retval : None
*/
void spi_flash_raddr(unsigned int ReadAddr,unsigned int NumByteToRead, unsigned char *pBuffer)
{
	/* Select the FLASH: Chip Select low */
	OS_CPU_SR  cpu_sr = 0;
	OS_ENTER_CRITICAL();
	SPI_FLASH_CS_LOW();

	/* Send "Read from Memory " instruction */
	spi_flash_send_byte(READ);

	/* Send ReadAddr high nibble address byte to read from */
	spi_flash_send_byte((ReadAddr & 0xFF0000) >> 16);
	/* Send ReadAddr medium nibble address byte to read from */
	spi_flash_send_byte((ReadAddr& 0xFF00) >> 8);
	/* Send ReadAddr low nibble address byte to read from */
	spi_flash_send_byte(ReadAddr & 0xFF);

	while (NumByteToRead--) /* while there is data to be read */
	{
		/* Read a byte from the FLASH */
		*pBuffer = spi_flash_send_byte(Dummy_Byte);
		/* Point to the next location where the byte read will be saved */
		pBuffer++;
	}

	/* Deselect the FLASH: Chip Select high */
	SPI_FLASH_CS_HIGH();
	OS_EXIT_CRITICAL();
}
开发者ID:joe3501,项目名称:BlueRing,代码行数:37,代码来源:spi_flash.c

示例5: spi_flash_page_write

/**
* @brief  Writes more than one byte to the FLASH with a single WRITE
*         cycle(Page WRITE sequence). The number of byte can't exceed
*         the FLASH page size.
* @param pBuffer : pointer to the buffer  containing the data to be
*                  written to the FLASH.
* @param WriteAddr : FLASH's internal address to write to.
* @param NumByteToWrite : number of bytes to write to the FLASH,
*                       must be equal or less than "SPI_FLASH_PageSize" value.
* @retval  0: 成功
*         -1: 超时
*/
int spi_flash_page_write(unsigned char* pBuffer, unsigned int WriteAddr, unsigned short NumByteToWrite)
{
	/* Enable the write access to the FLASH */
	OS_CPU_SR  cpu_sr = 0;
	OS_ENTER_CRITICAL();
	spi_flash_write_enable();

	/* Select the FLASH: Chip Select low */
	SPI_FLASH_CS_LOW();
	/* Send "Write to Memory " instruction */
	spi_flash_send_byte(WRITE);
	/* Send WriteAddr high nibble address byte to write to */
	spi_flash_send_byte((WriteAddr & 0xFF0000) >> 16);
	/* Send WriteAddr medium nibble address byte to write to */
	spi_flash_send_byte((WriteAddr & 0xFF00) >> 8);
	/* Send WriteAddr low nibble address byte to write to */
	spi_flash_send_byte(WriteAddr & 0xFF);

	/* while there is data to be written on the FLASH */
	while (NumByteToWrite--)
	{
		/* Send the current byte */
		spi_flash_send_byte(*pBuffer);
		/* Point on the next byte to be written */
		pBuffer++;
	}

	/* Deselect the FLASH: Chip Select high */
	SPI_FLASH_CS_HIGH();

	/* Wait the end of Flash writing */
	return spi_flash_wait_for_write_end();
}
开发者ID:joe3501,项目名称:BlueRing,代码行数:45,代码来源:spi_flash.c

示例6: SFlash_Read_Record

/*********************************************************************//**
 * @author             
 * @brief 	
 * @date 
 * @version  
 * @description 
 * @param[in]		None.
 * @param[out]		None.
 * @return 				             
 *                         
 **********************************************************************/
uint8_t SFlash_Read_Record(Record_t *readBuffer, uint32_t address)
{
	uint32_t i = 0;
	uint8_t *buff;
	if ((address) > NUM_OF_ALL_RECORD)
		return FALSE;


	address = address*RECORD_SIZE;
	SPI_FLASH_CS_LOW();
	Flash_ReadWriteByte(READ_OPCODE); 						// Send read command
//	Flash_ReadWriteByte(0x0B); 								// Send read command (high speed read)
	Flash_ReadWriteByte(address >> 16);						// Send 3 byte address command
	Flash_ReadWriteByte(address >> 8);
	Flash_ReadWriteByte(address);
//	Flash_ReadWriteByte(0xFF);						// for high speed read this line (dummy cycle) should be used
	buff = (uint8_t*)readBuffer;
	for ( i = 0; i < RECORD_SIZE; i++ )		
	{
      buff[i] = Flash_ReadWriteByte(0xFF);		/* Read data */
	}
  SPI_FLASH_CS_HIGH();
	//SFlash_Read_Data((uint8_t*)readBuffer, RECORD_SIZE, address*RECORD_SIZE);
	
	return TRUE;
}
开发者ID:saeedhadi,项目名称:Metering,代码行数:37,代码来源:FlashRTC.c

示例7: SPI_FLASH_WriteDisable

void SPI_FLASH_WriteDisable(void)
{
    SPI_FLASH_CS_LOW();
    SPI_FLASH_SendByte(WRDIS);
    SPI_FLASH_CS_HIGH();
    GPIO_ResetBits(GPIOC, GPIO_Pin_13);
}
开发者ID:xiamin,项目名称:Downloader,代码行数:7,代码来源:tad_SpiFlash.c

示例8: SPI_FLASH_WaitForWriteEnd

/**
  * @brief  Polls the status of the Write In Progress (WIP) flag in the
  *   FLASH's status  register  and  loop  until write  opertaion
  *   has completed.
  * @param  None
  * @retval : None
  */
void SPI_FLASH_WaitForWriteEnd(void)
{
    uint16_t i = 0;
    uint8_t FLASH_Status = 0;

    /* Select the FLASH: Chip Select low */
    SPI_FLASH_CS_LOW();

    /* Send "Read Status Register" instruction */
    SPI_FLASH_SendByte(RDSR);

    /* Loop as long as the memory is busy with a write cycle */
    do
    {
        /* Send a dummy byte to generate the clock needed by the FLASH
        and put the value of the status register in FLASH_Status variable */
        FLASH_Status = SPI_FLASH_GetByte();

        i++;
        if (i >= 60000) break;
    }
    while ((FLASH_Status & WIP_Flag) == SET); /* Write in progress */

    /* Deselect the FLASH: Chip Select high */
    SPI_FLASH_CS_HIGH();
    SPI_FLASH_WriteDisable();
}
开发者ID:xiamin,项目名称:Downloader,代码行数:34,代码来源:tad_SpiFlash.c

示例9: SPI_FLASH_Init

/**
  * @brief  Initializes the peripherals used by the SPI FLASH driver.
  * @param  None
  * @retval : None
  */
void SPI_FLASH_Init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure;
    uint8_t State1;
    Spi_Soft_Init();

    /* Enable SPI1 and GPIO clocks */
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIO_FLASH1_CS, ENABLE);

    /* Configure I/O for Flash Chip select */
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_FLASH1_CS;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIO_FLASH1_CS, &GPIO_InitStructure);

    /* Deselect the FLASH: Chip Select high */
    SPI_FLASH_CS_HIGH();
    
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOC, &GPIO_InitStructure);
    
    GPIO_SetBits(GPIOC, GPIO_Pin_13);     //flash写使能
    
    SPI_FLASH_ProtectSW(0);	//写使能
    #if 0
    State1 =  SPI_FLASH_ReadStatus(RDSR);
    if((State1 &0x9c)!=0x9c)
    {
        SPI_FLASH_WriteStatus(0x009c);		/* 使用软件保护模式,写的时候才使能 modify by FJD 20120905*/
    }
    #endif
}
开发者ID:xiamin,项目名称:Downloader,代码行数:40,代码来源:tad_SpiFlash.c

示例10: spi_flash_read_id

/**
* @brief  Reads FLASH identification.
* @param  None
* @retval : FLASH identification
*/
unsigned int spi_flash_read_id(void)
{
	unsigned int Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0;

	OS_CPU_SR  cpu_sr = 0;
	OS_ENTER_CRITICAL();
	/* Select the FLASH: Chip Select low */
	SPI_FLASH_CS_LOW();

	/* Send "RDID " instruction */
	spi_flash_send_byte(0x9F);

	/* Read a byte from the FLASH */
	Temp0 = spi_flash_send_byte(Dummy_Byte);

	/* Read a byte from the FLASH */
	Temp1 = spi_flash_send_byte(Dummy_Byte);

	/* Read a byte from the FLASH */
	Temp2 = spi_flash_send_byte(Dummy_Byte);

	/* Deselect the FLASH: Chip Select high */
	SPI_FLASH_CS_HIGH();

	Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2;

	OS_EXIT_CRITICAL();
	return Temp;
}
开发者ID:joe3501,项目名称:BlueRing,代码行数:34,代码来源:spi_flash.c

示例11: SFlash_Enable_Write_Status_Register

/*********************************************************************//**
 * @author             
 * @brief 	
 * @date 
 * @version  
 * @description 
 * @param[in]		None.
 * @param[out]		None.
 * @return 				             
 *                         
 **********************************************************************/
void SFlash_Enable_Write_Status_Register(void)
{
	//SFlash_Write_Enable();
	SPI_FLASH_CS_LOW();
	Flash_ReadWriteByte(EWSR_OPCODE);
	SPI_FLASH_CS_HIGH();
}
开发者ID:saeedhadi,项目名称:Metering,代码行数:18,代码来源:FlashRTC.c

示例12: SPI_FLASH_CS_LOW

/*static void w25x64_write_disable(void)
{
  SPI_FLASH_CS_LOW();
  SPI_FLASH_SendByte(WriteDisable);
  SPI_FLASH_CS_HIGH();
}*/
void w25x64_read(unsigned int addr,void *pbuf,unsigned int bytes)
{
	u8* data_buf = pbuf;
	if(addr+bytes>W25X64_SIZE)
		return;
  /* Select the FLASH: Chip Select low */
  SPI_FLASH_CS_LOW();

  /* Send "Read from Memory " instruction */
  SPI_FLASH_SendByte(Read_Data);

  /* Send ReadAddr high nibble address byte to read from */
  SPI_FLASH_SendByte((addr & 0xFF0000) >> 16);
  /* Send ReadAddr medium nibble address byte to read from */
  SPI_FLASH_SendByte((addr& 0xFF00) >> 8);
  /* Send ReadAddr low nibble address byte to read from */
  SPI_FLASH_SendByte(addr & 0xFF);

  while (bytes--) /* while there is data to be read */
  {
    /* Read a byte from the FLASH */
    *data_buf = SPI_FLASH_SendByte(Dummy_Byte);
    /* Point to the next location where the byte read will be saved */
    data_buf++;
  }

  /* Deselect the FLASH: Chip Select high */
  SPI_FLASH_CS_HIGH();
}
开发者ID:bearxiong99,项目名称:XXOO_000,代码行数:35,代码来源:W25X64.c

示例13: SPI_FLASH_BufferRead

/**
  * @brief  Reads a block of data from the FLASH.
  * @param pBuffer : pointer to the buffer that receives the data read
  *                  from the FLASH.
  * @param ReadAddr : FLASH's internal address to read from.
  * @param NumByteToRead : number of bytes to read from the FLASH.
  * @retval : None
  */
void SPI_FLASH_BufferRead(uint8_t* pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead)
{
    /* Select the FLASH: Chip Select low */
    SPI_FLASH_CS_LOW();

    /* Send "Read from Memory " instruction */
    SPI_FLASH_SendByte(READ);

    /* Send ReadAddr high nibble address byte to read from */
    SPI_FLASH_SendByte((ReadAddr & 0xFF0000) >> 16);
    /* Send ReadAddr medium nibble address byte to read from */
    SPI_FLASH_SendByte((ReadAddr& 0xFF00) >> 8);
    /* Send ReadAddr low nibble address byte to read from */
    SPI_FLASH_SendByte(ReadAddr & 0xFF);

    while (NumByteToRead--) /* while there is data to be read */
    {
        /* Read a byte from the FLASH */
        *pBuffer = SPI_FLASH_SendByte(Dummy_Byte);
        /* Point to the next location where the byte read will be saved */
        pBuffer++;
    }

    /* Deselect the FLASH: Chip Select high */
    SPI_FLASH_CS_HIGH();
}
开发者ID:jiesse,项目名称:time-meter,代码行数:34,代码来源:spi_flash.c

示例14: SPI_FLASH_ReadID

/**
  * @brief  Reads FLASH identification.
  * @param  None
  * @retval : FLASH identification
  */
uint32_t SPI_FLASH_ReadID(void)
{
    uint32_t Temp = 0, Temp0 = 0, Temp1 = 0, Temp2 = 0;

    /* Select the FLASH: Chip Select low */
    SPI_FLASH_CS_LOW();

    /* Send "RDID " instruction */
    SPI_FLASH_SendByte(0x9F);

    /* Read a byte from the FLASH */
    Temp0 = SPI_FLASH_SendByte(Dummy_Byte);

    /* Read a byte from the FLASH */
    Temp1 = SPI_FLASH_SendByte(Dummy_Byte);

    /* Read a byte from the FLASH */
    Temp2 = SPI_FLASH_SendByte(Dummy_Byte);

    /* Deselect the FLASH: Chip Select high */
    SPI_FLASH_CS_HIGH();

    Temp = (Temp0 << 16) | (Temp1 << 8) | Temp2;

    return Temp;
}
开发者ID:jiesse,项目名称:time-meter,代码行数:31,代码来源:spi_flash.c

示例15: SPI_FLASH_PageWrite

/******************************************************************************************
*函数名:SPI_FLASH_PageWrite()
* 参数:uint8_t* pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite 数据指针,写入地址,写入的个数
* 返回值:void
* 功能:SPIFLASH页写入数据函数,外部调用
*********************************************************************************************/
void SPI_FLASH_PageWrite(uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite)
{
    /*使能写入*/
    SPI_FLASH_WriteEnable();
    /*使能片选*/
    SPI_FLASH_CS_LOW();
    /* 发送页写入指令*/
    SSP0_SendByte(W25X_PageProgram);
    /*发送高8位数据地址*/
    SSP0_SendByte((WriteAddr & 0xFF0000) >> 16);
    /*发送中8位数据地址*/
    SSP0_SendByte((WriteAddr & 0xFF00) >> 8);
    /*发送低8位数据地址*/
    SSP0_SendByte(WriteAddr & 0xFF);
    /*检测写入的数据是否超出页的容量大小*/
    if (NumByteToWrite > SPI_FLASH_PerWritePageSize)
    {
        NumByteToWrite = SPI_FLASH_PerWritePageSize;
    }
    /*循环写入数据*/
    while (NumByteToWrite--)
    {
        /*发送数据*/
        SSP0_SendByte(*pBuffer);
        /* 指针移到下一个写入数据 */
        pBuffer++;
    }
    /*失能片选*/
    SPI_FLASH_CS_HIGH();
    /* 等待写完成*/
    SPI_FLASH_WaitForWriteEnd();
}
开发者ID:nongxiaoming,项目名称:nxp_boot,代码行数:38,代码来源:drv_spiflash.c


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