/** * Esta funcion retorna un comando desde el fligh plan. Lee desde la SD el * i-esimo comando y su parametro. * @param index Index-esimo dato del fligh plan */ DispCmd dat_get_FlightPlan(unsigned int index) { DispCmd NewCmd; NewCmd.cmdId = CMD_CMDNULL; NewCmd.param = 0; NewCmd.idOrig = -1; NewCmd.sysReq = -1; if(index < SCH_TFLIGHTPLAN_N_CMD) { int cmd_id, cmd_param; // La organizacion de los datos en la SD es // Primera mitad comandos, segunda mitad parametros #if (SCH_TFLIGHTPLAN_EXTMEMORY == 1) msd_getVar_256BlockExtMem(dat_gpb_FlightPlan_256Block, index, &cmd_id); msd_getVar_256BlockExtMem(dat_gpb_FlightPlan_256Block, 0xFFFF - index, &cmd_param); #elif (SCH_TFLIGHTPLAN_EXTMEMORY == 0) cmd_id = DAT_FPLAN_BUFF[index];//Comandos cmd_param = DAT_FPLAN_BUFF[index+SCH_TFLIGHTPLAN_N_CMD]; //Parametros #endif NewCmd.cmdId = cmd_id; NewCmd.param = cmd_param; } return NewCmd; }
void drp_debug3(void){ int value=0, res=0; unsigned int index; unsigned long block; con_printf("(Destructive) Testing -256block r/w- memSD\r\n"); for(block=0; block<1024; block=block+256){ printf("testing 256Block = %lu\n", block); value=20000; for(index=0; index<=0xFFFF; index++, value++){ con_printf("writing: "); msd_setVar_256BlockExtMem( block, index, value); printf("value[%u] = %d | ", index, value); printf("reading: "); msd_getVar_256BlockExtMem( block, index, &res); printf("value[%u] = %d | ", index, res); printf("comparing: "); if( value==res ){ printf("ok\n"); } else{ con_printf("fail\n"); return; } ClrWdt(); } } //drp_memSD_BlockErase(); }
//****************************************************************************** // DAT_AuxBuff //****************************************************************************** //Get int dat_get_Aux_Buff(DAT_Aux_Buff aux_i, unsigned int indx) { int val; unsigned long block = dat_aux_i_to_block(aux_i); msd_getVar_256BlockExtMem(block, indx, &val); return val; }
//Retorna FALSE si el indiex es invalido, TRUE si todo OK BOOL dat_get_Payload_Buff(DAT_Payload_Buff pay_i, unsigned int indx, int *value) { unsigned int desiredIndx, nextIndx; // Descarta si pay_i invalido if(pay_i>=dat_pay_last_one) { #if (SCH_DATAREPOSITORY_VERBOSE>=1) printf("dat_get_Payload_Buff: invalid payload\n"); #endif return FALSE; //payload invalido } // Descarta si indx invalido (fuera de rango) desiredIndx = indx; //maxIndx = dat_get_MaxPayIndx(pay_i); nextIndx = dat_get_NextPayIndx(pay_i); if(desiredIndx > nextIndx) { #if (SCH_DATAREPOSITORY_VERBOSE>=1) printf("dat_get_PayloadBuff: indx > nextIndx (%04u)\n", nextIndx); #endif return FALSE; } //obtengo el valor de value unsigned long block = dat_pay_i_to_block(pay_i); msd_getVar_256BlockExtMem(block, desiredIndx, value); return TRUE; }
/** * Obtiene el i-esima valor del buffer de Telecomandos * @param indx Posicion del buffer a recuperar * @return indx-esima posicion del Buffer */ int dat_get_TeleCmd_Buff(int indx) { int data; if(indx>=DAT_MAX_BUFF_TELECMD) { return 0; } else { #if (SCH_TFLIGHTPLAN_EXTMEMORY == 0 || SCH_SYSBUS_ONBOARD==0) data = DAT_CMD_BUFF[indx]; #else msd_getVar_256BlockExtMem(dat_gpb_TeleCmd_256Block, indx, &data); #endif return data; } }
//Obtiene el valor del indice actual del buffer de cierto payload unsigned int dat_get_NextPayIndx(DAT_Payload_Buff pay_i) { unsigned int nextIndx; msd_getVar_256BlockExtMem(dat_gpb_Pay_nextIndx_256Block, (unsigned char)pay_i, (int *)&nextIndx); return nextIndx; }
//Obtiene el valor del ultimo/maximo indice del buffer de cierto payload unsigned int dat_get_MaxPayIndx(DAT_Payload_Buff pay_i) { unsigned int maxIndx; msd_getVar_256BlockExtMem(dat_gpb_Pay_maxIndx_256Block, (unsigned char)pay_i, (int *)&maxIndx); return maxIndx; }