fmc_state_enum fmc_word_program(uint32_t address, uint32_t data) { fmc_state_enum fmc_state = FMC_READY; if(FMC_BANK0_SIZE < FMC_SIZE){ if(FMC_BANK0_END_ADDRESS > address){ fmc_state = fmc_bank0_ready_wait(FMC_TIMEOUT_COUNT); if(FMC_READY == fmc_state){ /* set the PG bit to start program */ FMC_CTL0 |= FMC_CTL0_PG; REG32(address) = data; /* wait for the FMC ready */ fmc_state = fmc_bank0_ready_wait(FMC_TIMEOUT_COUNT); /* reset the PG bit */ FMC_CTL0 &= ~FMC_CTL0_PG; } }else{ fmc_state = fmc_bank1_ready_wait(FMC_TIMEOUT_COUNT); if(FMC_READY == fmc_state){ /* set the PG bit to start program */ FMC_CTL1 |= FMC_CTL1_PG; REG32(address) = data; /* wait for the FMC ready */ fmc_state = fmc_bank1_ready_wait(FMC_TIMEOUT_COUNT); /* reset the PG bit */ FMC_CTL1 &= ~FMC_CTL1_PG; } } }else{ fmc_state = fmc_bank0_ready_wait(FMC_TIMEOUT_COUNT); if(FMC_READY == fmc_state){ /* set the PG bit to start program */ FMC_CTL0 |= FMC_CTL0_PG; REG32(address) = data; /* wait for the FMC ready */ fmc_state = fmc_bank0_ready_wait(FMC_TIMEOUT_COUNT); /* reset the PG bit */ FMC_CTL0 &= ~FMC_CTL0_PG; } } /* return the FMC state */ return fmc_state; }
时间: 2024-02-15 10:27:58 浏览: 335
FMC使用指南使用说明使用介绍
这段代码看起来是一个烧录器或者编程器的代码,用于将数据写入地址中。函数名是fmc_word_program,输入参数是要写入的地址和数据。代码中首先判断FMC_BANK0_SIZE是否小于FMC_SIZE,如果是,则说明只有一个FMC BANK可以使用,否则有两个可以使用。然后根据地址所在的FMC BANK,调用相应的fmc_bank_ready_wait函数等待FMC就绪。如果FMC就绪,则设置PG位开始编程,将数据写入地址中,等待FMC再次就绪后,清除PG位。最后返回FMC状态。
阅读全文