cancel
Showing results for 
Search instead for 
Did you mean: 

USB Superspeed Peripherals

New Contributor II

CyU3PReturnStatus_t write_data(void)//向flash写入数据

{

   unsigned char flash_write[4]={0};

unsigned char flash_read[4]={0};

   CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

   unsigned char wp[10]={0x01};

   flash_write[0] =Flag ;flash_write[1] =2 ;flash_write[2] = 2;flash_write[3] = 3;

   status=CyFxSpiEraseSector(1,7,wp);

   if(status != CY_U3P_SUCCESS){

      CyU3PDebugPrint (4, "Erase Error: %x\r\n",status);

   }

   status=CyFxSpiTransfer(1792,4,flash_write,0);//向flash写入数据

   if(status != CY_U3P_SUCCESS){

      CyU3PDebugPrint (4, "Write Error: %x\r\n",status);

   }//*/

//   status = CyFxSpiTransfer(1792,4,flash_read,1);//从flash中读取数据

//        if(status != CY_U3P_SUCCESS){

//           CyU3PDebugPrint (4, "\r\nRead Error: %x\r\n",status);

//        }

   return status;

}

CyU3PReturnStatus_t read_data(void)//从flash中读取数据

{

    unsigned char flash_read[4]={0};

    CyU3PReturnStatus_t status = CY_U3P_SUCCESS;

    CyFxSpiTransfer(1792,4,flash_read,1);//从flash中读取数据

    Flag=flash_read[0];

    return CY_U3P_SUCCESS;//Flag;

}

0 Likes
Reply
1 Solution
2 Replies