miniFOC 1.0.3
This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.
Macros | Functions
flash.c File Reference

this file contains the code implementation of on-chip flash reading, writing and erasing, as well as storing and reading user configurations. More...

#include "main.h"

Go to the source code of this file.

Macros

#define JUDGE_AVAILABLE(x, minimum, maximum)
 determine whether the read-out variable is within the trusted range More...
 

Functions

void flash_write_parameters (void)
 program all parameters to flash More...
 
void flash_read_parameters (void)
 read all parameters from flash More...
 
void flash_erase_page (void)
 erase flash page in last sector More...
 
void flash_program_word (unsigned int addr, unsigned int *data, unsigned char counter)
 program flash word to address More...
 
unsigned int flash_read_word (unsigned int addr)
 read flash word from address More...
 

Detailed Description

this file contains the code implementation of on-chip flash reading, writing and erasing, as well as storing and reading user configurations.

Author
Lao·Zhu
Version
V1.0.2
Date
29. October 2021

Definition in file flash.c.

Macro Definition Documentation

◆ JUDGE_AVAILABLE

#define JUDGE_AVAILABLE (   x,
  minimum,
  maximum 
)
Value:
if (x > maximum || x < minimum) \
x = 0

determine whether the read-out variable is within the trusted range

Parameters
[in]xvariables to be judged
[in]minimumthe minimum value of this variable
[in]maximumthe maximum value of this variable

Definition at line 20 of file flash.c.

Function Documentation

◆ flash_erase_page()

void flash_erase_page ( void  )

erase flash page in last sector

Definition at line 76 of file flash.c.

References FMC_WRITE_START_ADDR.

Referenced by flash_write_parameters().

◆ flash_program_word()

void flash_program_word ( unsigned int  addr,
unsigned int *  data,
unsigned char  counter 
)

program flash word to address

Parameters
[in]addraddress to write to
[in]datadata to be written
[in]counternumber of bytes to be written to flash

Definition at line 95 of file flash.c.

References FMC_WRITE_START_ADDR.

Referenced by flash_write_parameters().

◆ flash_read_parameters()

void flash_read_parameters ( void  )

◆ flash_read_word()

unsigned int flash_read_word ( unsigned int  addr)

read flash word from address

Parameters
[in]addraddress to read from
Return values
dataread from address

Definition at line 114 of file flash.c.

References FMC_WRITE_START_ADDR.

Referenced by flash_read_parameters().

◆ flash_write_parameters()

void flash_write_parameters ( void  )