Exemple #1
0
/**********************************************************************
functionName:void pcm_save(void)
description:保存系统参数到flash(必须首先执行eep_erase) 
**********************************************************************/ 
void pcm_save(void)
{
	#if 	defined	USE_PCM_SD_SAVE
		pcm_save_sd();
	#elif 	defined USE_PCM_INSIDE_FLASH_SAVE
		eep_write(pcm_ram,PCM_DATA_BASE,PCM_MEM_SIZE);
	#elif 	defined USE_PCM_OUTSIDE_FLASH_SAVE
		sf_WriteBuffer(pcm_ram,PCM_DATA_BASE,PCM_MEM_SIZE);
	#endif
	
//	eep_write(pcm_ram,PCM_DATA_BASE,PCM_MEM_SIZE);	
//	pcm_save_sd();
//	sf_WriteBuffer(pcm_ram,PCM_DATA_BASE,PCM_MEM_SIZE);
}
Exemple #2
0
/**********************************************************************
* Function:        void load_param(void)
* PreCondition:    None
* Input:		   None
* Output:		   None
* Side Effects:
* Overview:		   Load parameters from EEPROM
***********************************************************************/
void load_param(void)
{
    unsigned char adr;
    unsigned int signature, nb_essai = 3;

    adr = 0;
    while (--nb_essai && signature != EEP_SIGNATURE)
    {
        eep_read(adr, (unsigned char *)&signature, sizeof(signature));
    }

    adr += sizeof(signature);
    if (signature == EEP_SIGNATURE)
    {
        eep_adr_config_byte = adr;
        eep_read(adr, (unsigned char *)&config_byte.byte, sizeof(config_byte.byte));
        adr += sizeof(config_byte.byte);

        eep_adr_stepper_delay_manual = adr;
        eep_read(adr, (unsigned char *)&stepper_delay_manual, sizeof(stepper_delay_manual));
        adr += sizeof(stepper_delay_manual);

        eep_adr_stepper_delay_auto = adr;
        eep_read(adr, (unsigned char *)&stepper_delay_auto, sizeof(stepper_delay_auto));
        adr += sizeof(stepper_delay_auto);

        eep_adr_stepper_pos_max = adr;
        eep_read(adr, (unsigned char *)&stepper_pos_max, sizeof(stepper_pos_max));
        adr += sizeof(stepper_pos_max);

        eep_adr_stepper_pos_min = adr;
        eep_read(adr, (unsigned char *)&stepper_pos_min, sizeof(stepper_pos_min));
        adr += sizeof(stepper_pos_min);

        eep_adr_stepper_position = adr;
        eep_read(adr, (unsigned char *)&stepper_position, sizeof(stepper_position));
        adr += sizeof(stepper_position);

        eep_adr_stepper_backlash = adr;
        eep_read(adr, (unsigned char *)&stepper_backlash, sizeof(stepper_backlash));
        adr += sizeof(stepper_backlash);

        eep_adr_temperature_coef = adr;
        eep_read(adr, (unsigned char *)&temperature_coef, sizeof(temperature_coef));
        adr += sizeof(temperature_coef);

        eep_adr_p_step_sequencer = adr;
        eep_read(adr, (unsigned char *)&p_step_sequencer, sizeof(p_step_sequencer));
        adr += sizeof(p_step_sequencer);

        eep_adr_pwr_threshold = adr;
        eep_read(adr, (unsigned char *)&pwr_threshold, sizeof(pwr_threshold));
        adr += sizeof(pwr_threshold);
    }
    else
    {
        // bad signature, writing default values
        eep_adr_config_byte = adr;
        eep_write(adr, (unsigned char *)&config_byte.byte, sizeof(config_byte.byte));
        adr += sizeof(config_byte.byte);

        eep_adr_stepper_delay_manual = adr;
        eep_write(adr, (unsigned char *)&stepper_delay_manual, sizeof(stepper_delay_manual));
        adr += sizeof(stepper_delay_manual);

        eep_adr_stepper_delay_auto = adr;
        eep_write(adr, (unsigned char *)&stepper_delay_auto, sizeof(stepper_delay_auto));
        adr += sizeof(stepper_delay_auto);

        eep_adr_stepper_pos_max = adr;
        eep_write(adr, (unsigned char *)&stepper_pos_max, sizeof(stepper_pos_max));
        adr += sizeof(stepper_pos_max);

        eep_adr_stepper_pos_min = adr;
        eep_write(adr, (unsigned char *)&stepper_pos_min, sizeof(stepper_pos_min));
        adr += sizeof(stepper_pos_min);

        eep_adr_stepper_position = adr;
        eep_write(adr, (unsigned char *)&stepper_position, sizeof(stepper_position));
        adr += sizeof(stepper_position);

        eep_adr_stepper_backlash = adr;
        eep_write(adr, (unsigned char *)&stepper_backlash, sizeof(stepper_backlash));
        adr += sizeof(stepper_backlash);

        eep_adr_temperature_coef = adr;
        eep_write(adr, (unsigned char *)&temperature_coef, sizeof(temperature_coef));
        adr += sizeof(temperature_coef);

        eep_adr_p_step_sequencer = adr;
        eep_write(adr, (unsigned char *)&p_step_sequencer, sizeof(p_step_sequencer));
        adr += sizeof(p_step_sequencer);

        eep_adr_pwr_threshold = adr;
        eep_write(adr, (unsigned char *)&pwr_threshold, sizeof(pwr_threshold));
        adr += sizeof(pwr_threshold);

        signature = EEP_SIGNATURE;
        eep_write(0, (unsigned char *)&signature, sizeof(signature));
    }
}