/** * Initialize the on-chip timer controller. We snag TMU channel 2 in its * highest resolution mode, and start it counting down from max_int. */ void timer_init() { unsigned int val = byte_read(TSTR); byte_write( TSTR, val & (~(1<<TMU_CHANNEL)) ); /* Stop counter */ long_write( TCOR(TMU_CHANNEL), 0xFFFFFFFF ); long_write( TCNT(TMU_CHANNEL), 0xFFFFFFFF ); word_write( TCR(TMU_CHANNEL), 0x00000000 ); }
static BitSWindow *window_read(FILE *fp) { uint8_t sa[3],ea[3]; int nbytes,i; BitSWindow *rv; sa[0]=byte_read(fp); sa[1]=byte_read(fp); sa[2]=byte_read(fp); ea[0]=byte_read(fp); ea[1]=byte_read(fp); ea[2]=byte_read(fp); nbytes=a2nb(sa,ea); #ifdef TEST printf("Reading Window\n"); printf("sa: %d, %d, %d,\n",sa[0],sa[1],sa[2]); printf("ea: %d, %d, %d,\n",ea[0],ea[1],ea[2]); printf("nbytes: %d\n",nbytes); #endif rv=calloc(1,sizeof(*rv)+nbytes); assert(rv); for(i=0;i<3;i++) { rv->sa[i]=sa[i]; rv->ea[i]=ea[i]; } for(i=0;i<nbytes;i++) { rv->bytes[i]=byte_read(fp); } return rv; }
bool fwh_read_address(FWH *fwh, uint32_t addr, uint8_t *byte) { fwh_start(fwh, FWH_START_READ); fwh_nibble_write(fwh, 0); /* IDSEL hardwired */ fwh_send_imaddr(fwh, addr); fwh_nibble_write(fwh, 0); /* IMSIZE single byte */ nibble_set_dir(fwh->nibble, INPUT); clock_cycle(fwh->clock); if (!nibble_ready_sync(fwh->clock, fwh->nibble)) return false; *byte = byte_read(fwh->clock, fwh->nibble); clock_cycle(fwh->clock); nibble_set_dir(fwh->nibble, OUTPUT); fwh_nibble_write(fwh, 0xf); clock_cycle(fwh->clock); return true; }
/* look for identical bytes 3 bytes apart except zero coz 2many */ void p_addr(char * file) { FILE * fp; int nw,i,ri; int n; int rbuf[4]; fp=fopen(file,"rt"); assert(fp); byte_read(fp); byte_read(fp); for(i=0;i<4;i++) { byte_read(fp); } nw=0; nw=(byte_read(fp)&0x0ff)<<8; nw|=(byte_read(fp)&0x0ff); printf("num windows: %d\n",nw); for(i=0;i<4;i++) rbuf[i]=byte_read(fp); n=8; ri=0; while(1) { if((rbuf[ri]==rbuf[(ri+3)%4])&& (rbuf[ri]!=0)) { printf("byte%d: %d\n",n,rbuf[ri]); } n++; ri=(ri+1)%4; rbuf[(ri+3)%4]=byte_read(fp); if(feof(fp)) break; } fclose(fp); }
int bitSRead(BitStream *bs,char * file) { FILE * fp; int nw,i; memset(bs,0,sizeof(*bs)); dlistInit(&bs->windows); fp=fopen(file,"rt"); assert(fp); bs->nu=byte_read(fp); assert(0==bs->nu); bs->pe=byte_read(fp); assert(bs->pe==0xb7); for(i=0;i<4;i++) { bs->cregs[i]=byte_read(fp); } // bs->idunno=byte_read(fp); assert(get_cr(28)==0);//reserved==0 nw=0; nw=(byte_read(fp)&0x0ff)<<8; nw|=(byte_read(fp)&0x0ff); for(i=0;i<nw;i++) { BitSWindow * w; w=window_read(fp); dlistInsertLast(&bs->windows,&w->e); } bs->po=byte_read(fp); assert(bs->po==0xe7); fclose(fp); return 0; }
/*********************************************************************** [function]: callback: burn the FW to ctpm. [parameters]: pbt_buf[in]: point to Head+FW ; dw_lenth[in]: the length of the FW + 6(the Head length); [return]: ERR_OK: no error; ERR_MODE: fail to switch to UPDATE mode; ERR_READID: read id fail; ERR_ERASE: erase chip fail; ERR_STATUS: status error; ERR_ECC: ecc error. ************************************************************************/ E_UPGRADE_ERR_TYPE fts_ctpm_fw_upgrade(u8* pbt_buf, int dw_lenth) { u8 cmd,reg_val[2] = {0}; u8 buffer[2] = {0}; u8 packet_buf[FTS_PACKET_LENGTH + 6]; u8 auc_i2c_write_buf[10]; u8 bt_ecc; int j,temp,lenght,i_ret,packet_number, i = 0; int i_is_new_protocol = 0; /******write 0xaa to register 0xfc******/ cmd=0xaa; fts_register_write(0xfc,&cmd); mdelay(50); /******write 0x55 to register 0xfc******/ cmd=0x55; fts_register_write(0xfc,&cmd); printk("[TSP] Step 1: Reset CTPM test\n"); mdelay(10); /*******Step 2:Enter upgrade mode ****/ printk("\n[TSP] Step 2:enter new update mode\n"); auc_i2c_write_buf[0] = 0x55; auc_i2c_write_buf[1] = 0xaa; do { i ++; i_ret = fts_i2c_txdata(auc_i2c_write_buf, 2); mdelay(5); } while(i_ret <= 0 && i < 10 ); if (i > 1) { i_is_new_protocol = 1; } /********Step 3:check READ-ID********/ cmd_write(0x90,0x00,0x00,0x00,4); byte_read(reg_val,2); if (reg_val[0] == 0x79 && reg_val[1] == 0x3) { printk("[TSP] Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]); } else { return ERR_READID; //i_is_new_protocol = 1; } /*********Step 4:erase app**********/ if (i_is_new_protocol) { cmd_write(0x61,0x00,0x00,0x00,1); } else { cmd_write(0x60,0x00,0x00,0x00,1); } mdelay(1500); printk("[TSP] Step 4: erase. \n"); /*Step 5:write firmware(FW) to ctpm flash*/ bt_ecc = 0; printk("[TSP] Step 5: start upgrade. \n"); dw_lenth = dw_lenth - 8; packet_number = (dw_lenth) / FTS_PACKET_LENGTH; packet_buf[0] = 0xbf; packet_buf[1] = 0x00; for (j=0; j<packet_number; j++) { temp = j * FTS_PACKET_LENGTH; packet_buf[2] = (u8)(temp>>8); packet_buf[3] = (u8)temp; lenght = FTS_PACKET_LENGTH; packet_buf[4] = (u8)(lenght>>8); packet_buf[5] = (u8)lenght; for (i=0; i<FTS_PACKET_LENGTH; i++) { packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i]; bt_ecc ^= packet_buf[6+i]; } byte_write(&packet_buf[0],FTS_PACKET_LENGTH + 6); mdelay(FTS_PACKET_LENGTH/6 + 1); if ((j * FTS_PACKET_LENGTH % 1024) == 0) { printk("[TSP] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH); } } if ((dw_lenth) % FTS_PACKET_LENGTH > 0) { temp = packet_number * FTS_PACKET_LENGTH; packet_buf[2] = (u8)(temp>>8); packet_buf[3] = (u8)temp; temp = (dw_lenth) % FTS_PACKET_LENGTH; packet_buf[4] = (u8)(temp>>8); packet_buf[5] = (u8)temp; for (i=0; i<temp; i++) { packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i]; bt_ecc ^= packet_buf[6+i]; } byte_write(&packet_buf[0],temp+6); mdelay(20); }
E_UPGRADE_ERR_TYPE fts_ctpm_fw_upgrade(struct i2c_client *client,FTS_BYTE* pbt_buf, FTS_DWRD dw_lenth) { // FTS_BYTE cmd_len = 0; FTS_BYTE reg_val[2] = {0}; FTS_DWRD i = 0; // FTS_BYTE ecc = 0; FTS_DWRD packet_number; FTS_DWRD j; FTS_DWRD temp; FTS_DWRD lenght; FTS_BYTE packet_buf[FTS_PACKET_LENGTH + 6]; FTS_BYTE auc_i2c_write_buf[10]; FTS_BYTE bt_ecc; /*********Step 1:Reset CTPM *****/ /*write 0xaa to register 0xfc*/ Fts_i2c_write(client,0xfc,0xaa); delay_ms(50); /*write 0x55 to register 0xfc*/ Fts_i2c_write(client,0xfc,0x55); pr_info("Step 1: Reset CTPM test\n"); delay_ms(40); /*********Step 2:Enter upgrade mode *****/ auc_i2c_write_buf[0] = 0x55; auc_i2c_write_buf[1] = 0xaa; i2c_master_send(client, auc_i2c_write_buf, 2); pr_info("Step 2: Enter update mode. \n"); /*********Step 3:check READ-ID***********************/ /*send the opration head*/ do{ if(i > 3) { return ERR_READID; } /*read out the CTPM ID*/ cmd_write(client,0x90,0x00,0x00,0x00,4); byte_read(client,reg_val,2); i++; pr_info("Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]); }while(reg_val[0] != 0x79 || reg_val[1] != 0x03); /*********Step 4:erase app*******************************/ cmd_write(client,0x61,0x00,0x00,0x00,1); delay_ms(1500); pr_info("Step 4: erase. \n"); /*********Step 5:write firmware(FW) to ctpm flash*********/ bt_ecc = 0; pr_info("Step 5: start upgrade. \n"); dw_lenth = dw_lenth - 8; packet_number = (dw_lenth) / FTS_PACKET_LENGTH; packet_buf[0] = 0xbf; packet_buf[1] = 0x00; for (j=0;j<packet_number;j++) { temp = j * FTS_PACKET_LENGTH; packet_buf[2] = (FTS_BYTE)(temp>>8); packet_buf[3] = (FTS_BYTE)temp; lenght = FTS_PACKET_LENGTH; packet_buf[4] = (FTS_BYTE)(lenght>>8); packet_buf[5] = (FTS_BYTE)lenght; for (i=0;i<FTS_PACKET_LENGTH;i++) { packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i]; bt_ecc ^= packet_buf[6+i]; } byte_write(client,&packet_buf[0],FTS_PACKET_LENGTH + 6); delay_ms(FTS_PACKET_LENGTH/6 + 1); if ((j * FTS_PACKET_LENGTH % 1024) == 0) { pr_info("upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH); } } if ((dw_lenth) % FTS_PACKET_LENGTH > 0) { temp = packet_number * FTS_PACKET_LENGTH; packet_buf[2] = (FTS_BYTE)(temp>>8); packet_buf[3] = (FTS_BYTE)temp; temp = (dw_lenth) % FTS_PACKET_LENGTH; packet_buf[4] = (FTS_BYTE)(temp>>8); packet_buf[5] = (FTS_BYTE)temp; for (i=0;i<temp;i++) { packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i]; bt_ecc ^= packet_buf[6+i]; } byte_write(client,&packet_buf[0],temp+6); delay_ms(20); }
int main(int argc, char *argv[]) { FILE * fp; Img40 m; uint8_t v; int nw,i,j; Actx gc; char buf[100]; fp=fopen("gi","rt"); assert(fp); img40Init(&m,16,16); v=byte_read(fp); assert(0==v); v=byte_read(fp); assert(v==0xb7); for(i=0;i<4;i++) { m.cr[i]=byte_read(fp); } // bs->idunno=byte_read(fp); // assert(get_cr(28)==0);//reserved==0 nw=0; nw=(byte_read(fp)&0x0ff)<<8; nw|=(byte_read(fp)&0x0ff); for(i=0;i<nw;i++) { uint8_t sa[3],ea[3]; sa[0]=byte_read(fp); sa[1]=byte_read(fp); sa[2]=byte_read(fp); ea[0]=byte_read(fp); ea[1]=byte_read(fp); ea[2]=byte_read(fp); printf("Window %d of %d\n",i,nw-1); printf("at line: %d\n",line_idx+1); printf("start: "); dump_addr(sa); printf("\n"); printf("end: "); dump_addr(ea); printf("\n"); img40SA(&m,sa,ea); while(!img40Put(&m,byte_read(fp))); } v=byte_read(fp); assert(v==0xe7); fclose(fp); sprintf(buf,"cells"); for(i=0;i<m.rows;i++) { for(j=0;j<m.cols;j++) { char nbf[20]; actxInit(&gc,64,40); cellDraw(&gc,0,0,0,get_cell(&m,j,i)); if((i==0)&&(j==0)) { drawOffs(&gc,0,0); drawStr(&gc,0,0,buf); } sprintf(buf,"cell %.2d %.2d",j,i); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); csetDraw(&gc,20,0,0,get_cset(&m,j,i)); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,!((i==0)&&(j==0))); actxClear(&gc); } } sprintf(buf,"sectorsh(vert repeaters)"); for(i=0;i<(m.rows/4+1);i++) { for(j=0;j<m.cols;j++) { char nbf[20]; actxInit(&gc,20,48); sectorDraw(&gc,0,0,0,1,get_hsector(&m,j,i)); if((i==0)&&(j==0)) { drawOffs(&gc,0,0); drawStr(&gc,0,0,buf); } sprintf(buf,"sector %.2d %.2d",j,i); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); } } sprintf(buf,"sectorsv(hrz repeaters)"); for(i=0;i<m.rows;i++) { for(j=0;j<(m.cols/4+1);j++) { char nbf[20]; actxInit(&gc,20,48); sectorDraw(&gc,0,0,0,0,get_vsector(&m,j,i)); if((i==0)&&(j==0)) { drawOffs(&gc,0,0); drawStr(&gc,0,0,buf); } sprintf(buf,"sector %.2d %.2d",j,i); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); } } sprintf(buf,"ioh"); for(i=0;i<m.rows;i++) { for(j=0;j<2;j++) { char nbf[20]; int k; uint8_t *p=get_ioh(&m,j,i); for(k=0;k<2;k++) { actxInit(&gc,80,14); ioDraw(&gc,0,0,0,p+k*4,k==1); if((i==0)&&(j==0)&&(k==0)) { drawOffs(&gc,0,0); drawStr(&gc,0,0,buf); } sprintf(buf,"ioh_%c %.2d %.2d",(k==0)?'p':'s',j,i); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); } } } sprintf(buf,"iov"); for(i=0;i<2;i++) { for(j=0;j<m.cols;j++) { char nbf[20]; int k; uint8_t *p=get_iov(&m,j,i); for(k=0;k<2;k++) { actxInit(&gc,80,14); ioDraw(&gc,0,0,0,p+k*4,k==1); if((i==0)&&(j==0)&&(k==0)) { drawOffs(&gc,0,0); drawStr(&gc,0,0,buf); } sprintf(buf,"iov_%c %.2d %.2d",(k==0)?'p':'s',j,i); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); } } } sprintf(buf,"mem"); for(i=0;i<(m.rows/4);i++) { for(j=0;j<(m.cols/4);j++) { char nbf[20]; uint8_t *p=get_mem(&m,j,i); actxInit(&gc,20,8); memDraw(&gc,0,0,0,p); if((i==0)&&(j==0)) { drawOffs(&gc,0,0); drawStr(&gc,0,0,buf); } sprintf(buf,"mem %.2d %.2d",j,i); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); } } sprintf(buf,"cols"); for(j=0;j<m.cols;j++) { char nbf[20]; uint8_t *p=get_col(&m,j); actxInit(&gc,20,10); colDraw(&gc,0,0,0,p,0); if(j==0) { drawOffs(&gc,0,0); drawStr(&gc,0,0,buf); } sprintf(buf,"col %.2d",j); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); if(j==(m.cols-1)) {//fclock actxInit(&gc,20,10); colDraw(&gc,0,0,0,p+1,2); sprintf(buf,"auxcol %.2d (fck)",j); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); // assert((p[1]&0x0fc)==0x0fc); } else if(j==0) {//fclock actxInit(&gc,20,10); colDraw(&gc,0,0,0,p+1,1); sprintf(buf,"auxcol %.2d (fck)",j); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); // assert((p[1]&0x0fc)==0x0fc); } else if(j==((m.cols/2)-1)) {//reset input actxInit(&gc,20,10); colDraw(&gc,0,0,0,p+1,3); sprintf(buf,"auxcol %.2d (rst)",j); drawOffs(&gc,0,0); drawStr(&gc,0,1,buf); sprintf(nbf,"c_dmp"); actxDump(&gc,nbf,1); actxClear(&gc); // assert((p[1]&0x0f0)==0x0f0); } // else // assert(p[1]==0xff); } img40Dump(&m); img40Clear(&m); return 0; }
void timer_run() { byte_write( TSTR, byte_read(TSTR) | (1<<TMU_CHANNEL) ); }
/* [function]: burn the FW to ctpm. [parameters]:(ref. SPEC) pbt_buf[in] :point to Head+FW ; dw_lenth[in]:the length of the FW + 6(the Head length); bt_ecc[in] :the ECC of the FW [return]: ERR_OK :no error; ERR_MODE :fail to switch to UPDATE mode; ERR_READID :read id fail; ERR_ERASE :erase chip fail; ERR_STATUS :status error; ERR_ECC :ecc error. */ static E_UPGRADE_ERR_TYPE ft5x0x_fw_upgrade(struct ft5x0x_data *ft5x0x, u8* pbt_buf, int dw_lenth) { int i = 0,j = 0,i_ret; int packet_number; int temp,lenght; u8 packet_buf[FTS_PACKET_LENGTH + 6]; u8 auc_i2c_write_buf[10]; u8 reg_val[2] = {0}; u8 ctpm_id[2] = {0}; u8 cmd[4]; u8 bt_ecc; /*********Step 1:Reset CTPM *****/ /*write 0xaa to register 0xfc*/ ft5x0x_write_reg(0xfc,0xaa); msleep(50); /*write 0x55 to register 0xfc*/ ft5x0x_write_reg(0xfc,0x55); printk("[FTS] Step 1: Reset CTPM.\n"); msleep(30); /*********Step 2:Enter upgrade mode *****/ auc_i2c_write_buf[0] = 0x55; auc_i2c_write_buf[1] = 0xaa; do{ i ++; i_ret = byte_write(auc_i2c_write_buf, 2); mdelay(5); }while(i_ret <= 0 && i < 5 ); msleep(20); /*********Step 3:check READ-ID**********/ if(ft5x0x->id == FT5606){ ctpm_id[0] = FT56_CTPM_ID_L; ctpm_id[1] = FT56_CTPM_ID_H; }else{ ctpm_id[0] = FT5X_CTPM_ID_L; ctpm_id[1] = FT5X_CTPM_ID_H; } cmd[0] = 0x90; cmd[1] = 0x00; cmd[2] = 0x00; cmd[3] = 0x00; cmd_write(cmd,4); byte_read(reg_val,2); if (reg_val[0] == ctpm_id[0] && reg_val[1] == ctpm_id[1]){ printk("[FTS] Step 3: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]); }else{ printk("[FTS] ID_ERROR: CTPM ID,ID1 = 0x%x,ID2 = 0x%x\n",reg_val[0],reg_val[1]); return ERR_READID; } cmd[0] = 0xcd; cmd_write(cmd,1); byte_read(reg_val,1); printk("[FTS] bootloader version = 0x%x\n", reg_val[0]); /******Step 4:erase app and panel paramenter area *********/ cmd[0] = 0x61; cmd_write(cmd,1); //erase app area msleep(1500); cmd[0] = 0x63; cmd_write(cmd,1); //erase panel parameter area msleep(100); printk("[FTS] Step 4: erase. \n"); /*********Step 5:write firmware(FW) to ctpm flash*********/ bt_ecc = 0; printk("[FTS] Step 5: start upgrade. \n"); dw_lenth = dw_lenth - 8; packet_number = (dw_lenth) / FTS_PACKET_LENGTH; packet_buf[0] = 0xbf; packet_buf[1] = 0x00; for (j=0;j<packet_number;j++){ temp = j * FTS_PACKET_LENGTH; packet_buf[2] = (u8)(temp>>8); packet_buf[3] = (u8)temp; lenght = FTS_PACKET_LENGTH; packet_buf[4] = (u8)(lenght>>8); packet_buf[5] = (u8)lenght; for (i=0;i<FTS_PACKET_LENGTH;i++){ packet_buf[6+i] = pbt_buf[j*FTS_PACKET_LENGTH + i]; bt_ecc ^= packet_buf[6+i]; } byte_write(&packet_buf[0],FTS_PACKET_LENGTH + 6); mdelay(FTS_PACKET_LENGTH/6 + 1); if ((j * FTS_PACKET_LENGTH % 1024) == 0){ printk("[FTS] upgrade the 0x%x th byte.\n", ((unsigned int)j) * FTS_PACKET_LENGTH); } } if ((dw_lenth) % FTS_PACKET_LENGTH > 0){ temp = packet_number * FTS_PACKET_LENGTH; packet_buf[2] = (u8)(temp>>8); packet_buf[3] = (u8)temp; temp = (dw_lenth) % FTS_PACKET_LENGTH; packet_buf[4] = (u8)(temp>>8); packet_buf[5] = (u8)temp; for (i=0;i<temp;i++){ packet_buf[6+i] = pbt_buf[ packet_number*FTS_PACKET_LENGTH + i]; bt_ecc ^= packet_buf[6+i]; } byte_write(&packet_buf[0],temp+6); mdelay(20); }
static int uint8_read(idmef_value_type_t *dst, const char *buf) { return byte_read(dst, buf, 0, REQUIEM_UINT8_MAX); }
void main() { uchar shujv[8]; uchar stop=0; uchar cejv=1; uchar flag=0; uchar helpcejv=0; init_io(); led0=1;led1=1;ledk=1; while(NRF_Check()) { led0=0; delayms(1000); led0=1; delayms(1000); } TX_Mode(); //设置为发送模式 /*************自己加的***********************/ while(CNRF_Check()) //检查nrf是否存在 { led0=0; delayms(1000); led0=1; delayms(1000); } CTX_Mode(); /*************自己加的***********************/ stop=byte_read(0x2000); //读取上一次保留的值 while(1) { wenshi(shujv); //写入前4个数据 // yali(shujv);//写入第5个数据 // shache(shujv);//写入第六个数据 Get_weight(); if (weight_shiwu/1000<=5) shujv[4]='0'; else shujv[4]='1'; if(stop==0) shujv[5]='1'; if(stop==1) shujv[5]='0'; if(out==0) shujv[6]='1'; else shujv[6]='0'; ////////////////////////////// if(NRF24L01_TxPacket(shujv)==TX_OK) { led1=0; delayms(300); led1=1; delayms(10); ///// flag=1; } else flag=0; ////////////////////////////// if(flag==1) { if(CNRF24L01_TxPacket(shujv)==TX_OK) { led3=0; delayms(300); led3=1; delayms(10); cejv=0; helpcejv=0; } else { helpcejv++; delayms(100); if(helpcejv>2) { led2=0; delayms(300); led2=1; delayms(10); cejv=0; helpcejv=0; } } ///////////////////////////////////////////////// if(shache(cejv,stop)==1) { led0=0; delayms(300); led0=1; delayms(10); stop=1; SectorErase(0x2000); byte_write(0x2000,stop); } if(checkbutton(cejv,stop)==0) {stop=1; SectorErase(0x2000); byte_write(0x2000,stop); } } } }