SRD Standelone programmation box: FM25V20.h File Reference

| SRD Standelone programmation box 2.0 (16/11/15 10:00:00) Documentation of the SRD standelone programmation box

- Main Page
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Enumerations Enumerator Macros Pages
Data Structures | Macros | Enumerations | Functions
FM25V20.h File Reference

Headerfile for FRAM FM25V20 driver. More...

`#include "spi1.h"`
Include dependency graph for FM25V20.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Data Structures

union | tFM25V20StatusReg
| structure used to read and get the status register of the device. More...

## Macros

#define | FM25V20_SPI_BAUDRATE (10000000UL)
| Define the baudrate used by the communication interface with the FM25V20. More...
#define | FM25V20_DEVICE_ID_BYTE_SIZE (9U)
| Define the size of the device ID returned by the RDID opcode. More...
#define | FM25V20_SetWriteProtect(FM25V20_WriteProtectState) (PTB->PDOR = (PTB->PDOR & ~FM25V20_WP_MASK) | (FM25V20_WriteProtectState<<FM25V20_WP_SHIFT))
| Macro used to set the write protect state. More...
#define | FM25V20_SetHold(FM25V20_HoldState) (PTB->PDOR = (PTB->PDOR & ~FM25V20_HOLD_MASK) | (FM25V20_HoldState<<FM25V20_HOLD_SHIFT))
| Macro used to set the hold state. More...
#define | FM25V20_CS_SHIFT (4)
| Define the IO mask and shift used by the FM25V20 driver. More...
#define | FM25V20_CS_MASK (1<<FM25V20_CS_SHIFT)
| Define the IO mask and shift used by the FM25V20 driver. More...
#define | FM25V20_WP_SHIFT (18)
| Define the IO mask and shift used by the FM25V20 driver. More...
#define | FM25V20_WP_MASK (1<<FM25V20_WP_SHIFT)
| Define the IO mask and shift used by the FM25V20 driver. More...
#define | FM25V20_HOLD_SHIFT (19)
| Define the IO mask and shift used by the FM25V20 driver. More...
#define | FM25V20_HOLD_MASK (1<<FM25V20_HOLD_SHIFT)
| Define the IO mask and shift used by the FM25V20 driver. More...
#define | FM25V20_NBR_BIT (2097152UL)
| Define the memory number of bits and bytes available in this memory device. More...
#define | FM25V20_NBR_BYTE (FM25V20_NBR_BIT>>3)
| Define the memory number of bits and bytes available in this memory device. More...
#define | FM25V20_OPCODE_WREN (0b00000110)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_WRDI (0b00000100)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_RDSR (0b00000101)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_WRSR (0b00000001)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_READ (0b00000011)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_FSTRD (0b00001011)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_WRITE (0b00000010)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_SLEEP (0b10111001)
| Define the memory opcode. More...
#define | FM25V20_OPCODE_RDID (0b10011111)
| Define the memory opcode. More...

## Enumerations

enum | tFM25V20_HoldState { FM25V20_HOLD_ON = 0, FM25V20_HOLD_OFF = 1 }
| State used to control the hold line of the device. More...
enum | tFM25V20_WriteProtectState { FM25V20_WP_ON = 0, FM25V20_WP_OFF = 1 }
| State used to control the write protect line of the device. More...
enum | tFM25V20_AllowWrite { FM25V20_ALLOW_WRITE, FM25V20_FORBIDDEN_WRITE }
| enumeration used to enable/disable memory write operation. More...
enum | tFM25V20_LPMState { FM25V20_LowPowerMode = 1, FM25V20_WorkingMode = 0 }
| enumeration used to set the memory power mode. More...

## Functions

void | FM25V20Init (void)
| Function used to initialize the FM25V20 memory. More...
void | FM25V20_SetWriteEnable (tFM25V20_AllowWrite allowWrite)
| Function used to set the write mode. More...
signed char | FM25V20ReadDeviceId (unsigned char deviceId[FM25V20_DEVICE_ID_BYTE_SIZE])
| Function used to read the device ID. More...
void | FM25V20LPM (void)
| Put the memory in a low power mode. More...
void | FM25V20WakeUp (void)
| Wake up the memory from the low power mode. More...
signed char | FM25V20WriteData (unsigned long addr, unsigned char data[], unsigned long dataLength)
| Write data to the memory. More...
signed char | FM25V20ReadData (unsigned long addr, unsigned char data[], unsigned long dataLength)
| Read data from the memory. More...
tFM25V20_LPMState | FM25V20IsInLowPower (void)
| Get the low power status of the memory. More...
tFM25V20StatusReg | FM25V20ReadStatusReg (void)
| Functions used to set and read the status register. More...
void | FM25V20SetStatusReg (tFM25V20StatusReg status)
| Functions used to set and read the status register. More...

## Detailed Description

Headerfile for FRAM FM25V20 driver.

Author
  Thibaut LALUQUE 3D-Ouest

Date
  05/11/2014

Version
  1.0

All Right Reserved.

Definition in file FM25V20.h.

## Macro Definition Documentation

#define FM25V20_CS_MASK (1<<FM25V20_CS_SHIFT)

Define the IO mask and shift used by the FM25V20 driver.

Definition at line 38 of file FM25V20.h.

Referenced by FM25V20Init().

#define FM25V20_CS_SHIFT (4)

Define the IO mask and shift used by the FM25V20 driver.

Definition at line 37 of file FM25V20.h.

Referenced by FM25V20Init().

#define FM25V20_DEVICE_ID_BYTE_SIZE (9U)

Define the size of the device ID returned by the RDID opcode.

Definition at line 93 of file FM25V20.h.

#define FM25V20_HOLD_MASK (1<<FM25V20_HOLD_SHIFT)

Define the IO mask and shift used by the FM25V20 driver.

Definition at line 46 of file FM25V20.h.

Referenced by FM25V20Init().

#define FM25V20_HOLD_SHIFT (19)

Define the IO mask and shift used by the FM25V20 driver.

Definition at line 45 of file FM25V20.h.

Referenced by FM25V20Init().

#define FM25V20_NBR_BIT (2097152UL)

Define the memory number of bits and bytes available in this memory device.

Definition at line 66 of file FM25V20.h.

#define FM25V20_NBR_BYTE (FM25V20_NBR_BIT>>3)

Define the memory number of bits and bytes available in this memory device.

Definition at line 67 of file FM25V20.h.

Referenced by FM25V20MemTest_Clear(), FM25V20MemTest_HighFreqDown(), FM25V20MemTest_HighFreqUp(), FM25V20MemTest_PulseN(), FM25V20MemTest_PulseP(), and FM25V20MemTest_Set().

#define FM25V20_OPCODE_FSTRD (0b00001011)

Define the memory opcode.

Definition at line 82 of file FM25V20.h.

#define FM25V20_OPCODE_RDID (0b10011111)

Define the memory opcode.

Definition at line 85 of file FM25V20.h.

Referenced by FM25V20ReadDeviceId().

#define FM25V20_OPCODE_RDSR (0b00000101)

Define the memory opcode.

Definition at line 79 of file FM25V20.h.

Referenced by FM25V20ReadStatusReg().

#define FM25V20_OPCODE_READ (0b00000011)

Define the memory opcode.

Definition at line 81 of file FM25V20.h.

Referenced by FM25V20ReadData().

#define FM25V20_OPCODE_SLEEP (0b10111001)

Define the memory opcode.

Definition at line 84 of file FM25V20.h.

Referenced by FM25V20LPM().

#define FM25V20_OPCODE_WRDI (0b00000100)

Define the memory opcode.

Definition at line 78 of file FM25V20.h.

Referenced by FM25V20_SetWriteEnable().

#define FM25V20_OPCODE_WREN (0b00000110)

Define the memory opcode.

Definition at line 77 of file FM25V20.h.

Referenced by FM25V20_SetWriteEnable().

#define FM25V20_OPCODE_WRITE (0b00000010)

Define the memory opcode.

Definition at line 83 of file FM25V20.h.

Referenced by FM25V20WriteData().

#define FM25V20_OPCODE_WRSR (0b00000001)

Define the memory opcode.

Definition at line 80 of file FM25V20.h.

Referenced by FM25V20SetStatusReg().

#define FM25V20_SetHold | ( |  | FM25V20_HoldState | ) | (PTB->PDOR = (PTB->PDOR & ~FM25V20_HOLD_MASK) | (FM25V20_HoldState<<FM25V20_HOLD_SHIFT))

Macro used to set the hold state.

Definition at line 206 of file FM25V20.h.

#define FM25V20_SetWriteProtect | ( |  | FM25V20_WriteProtectState | ) | (PTB->PDOR = (PTB->PDOR & ~FM25V20_WP_MASK) | (FM25V20_WriteProtectState<<FM25V20_WP_SHIFT))

Macro used to set the write protect state.

Definition at line 198 of file FM25V20.h.

Referenced by FM25V20SetStatusReg(), and FM25V20WriteData().

#define FM25V20_SPI_BAUDRATE (10000000UL)

Define the baudrate used by the communication interface with the FM25V20.

Definition at line 57 of file FM25V20.h.

Referenced by FM25V20Init().

#define FM25V20_WP_MASK (1<<FM25V20_WP_SHIFT)

Define the IO mask and shift used by the FM25V20 driver.

Definition at line 42 of file FM25V20.h.

Referenced by FM25V20Init().

#define FM25V20_WP_SHIFT (18)

Define the IO mask and shift used by the FM25V20 driver.

Definition at line 41 of file FM25V20.h.

Referenced by FM25V20Init().

## Enumeration Type Documentation

enum tFM25V20_AllowWrite

enumeration used to enable/disable memory write operation.

Enumerator
FM25V20_ALLOW_WRITE | Write is allowed
FM25V20_FORBIDDEN_WRITE | Write is forbidden

Definition at line 150 of file FM25V20.h.

150 {
151 FM25V20_ALLOW_WRITE, /*!< Write is allowed */
152 FM25V20_FORBIDDEN_WRITE /*!< Write is forbidden */
153 }tFM25V20_AllowWrite;
FM25V20_FORBIDDEN_WRITE
Definition: FM25V20.h:152
tFM25V20_AllowWrite
tFM25V20_AllowWrite
enumeration used to enable/disable memory write operation.
Definition: FM25V20.h:150
FM25V20_ALLOW_WRITE
Definition: FM25V20.h:151

enum tFM25V20_HoldState

State used to control the hold line of the device.

Enumerator
FM25V20_HOLD_ON | Hold enable
FM25V20_HOLD_OFF | Hold disable

Definition at line 110 of file FM25V20.h.

110 {
111 FM25V20_HOLD_ON = 0, /*!< Hold enable */
112 FM25V20_HOLD_OFF = 1 /*!< Hold disable */
113 }tFM25V20_HoldState;
FM25V20_HOLD_ON
Definition: FM25V20.h:111
FM25V20_HOLD_OFF
Definition: FM25V20.h:112
tFM25V20_HoldState
tFM25V20_HoldState
State used to control the hold line of the device.
Definition: FM25V20.h:110

enum tFM25V20_LPMState

enumeration used to set the memory power mode.

Enumerator
FM25V20_LowPowerMode | Power mode is the low power mode
FM25V20_WorkingMode | Power mode is the active mode

Definition at line 161 of file FM25V20.h.

161 {
162 FM25V20_LowPowerMode = 1, /*!< Power mode is the low power mode */
163 FM25V20_WorkingMode = 0 /*!< Power mode is the active mode */
164 }tFM25V20_LPMState;
FM25V20_LowPowerMode
Definition: FM25V20.h:162
tFM25V20_LPMState
tFM25V20_LPMState
enumeration used to set the memory power mode.
Definition: FM25V20.h:161
FM25V20_WorkingMode
Definition: FM25V20.h:163

enum tFM25V20_WriteProtectState

State used to control the write protect line of the device.

Enumerator
FM25V20_WP_ON | Write protect enable
FM25V20_WP_OFF | Write protect disable

Definition at line 121 of file FM25V20.h.

121 {
122 FM25V20_WP_ON = 0, /*!< Write protect enable */
123 FM25V20_WP_OFF = 1 /*!< Write protect disable */
124 }tFM25V20_WriteProtectState;
FM25V20_WP_ON
Definition: FM25V20.h:122
FM25V20_WP_OFF
Definition: FM25V20.h:123
tFM25V20_WriteProtectState
tFM25V20_WriteProtectState
State used to control the write protect line of the device.
Definition: FM25V20.h:121

## Function Documentation

void FM25V20_SetWriteEnable | ( | tFM25V20_AllowWrite | allowWrite | ) |

Function used to set the write mode.

Parameters

  [in] | allowWrite | (tFM25V20_AllowWrite) : write protect state.

Definition at line 102 of file FM25V20.c.

References FM25V20_ALLOW_WRITE, FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_FORBIDDEN_WRITE, FM25V20_Lpm, FM25V20_OPCODE_WRDI, FM25V20_OPCODE_WREN, FM25V20_WorkingMode, Spi1GetEnable, and Spi1Send().

Referenced by FM25V20SetStatusReg(), and FM25V20WriteData().

102 {
103
104 if (Spi1GetEnable() && FM25V20_Lpm == FM25V20_WorkingMode) {
105
106 unsigned char data[1];
107
108 if (allowWrite == FM25V20_ALLOW_WRITE) {
109 data[0] = FM25V20_OPCODE_WREN;
110 } else if (allowWrite == FM25V20_FORBIDDEN_WRITE) {
111 data[0] = FM25V20_OPCODE_WRDI;
112 } else {
113 return; //It's not a rigth value
114 }
115
116 FM25V20_CS_Enable();
117 Spi1Send(data, 1);
118 FM25V20_CS_Disable();
119 }
120 }
FM25V20_FORBIDDEN_WRITE
Definition: FM25V20.h:152
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_OPCODE_WREN
#define FM25V20_OPCODE_WREN
Define the memory opcode.
Definition: FM25V20.h:77
FM25V20_OPCODE_WRDI
#define FM25V20_OPCODE_WRDI
Define the memory opcode.
Definition: FM25V20.h:78
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
Spi1GetEnable
#define Spi1GetEnable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:134
FM25V20_ALLOW_WRITE
Definition: FM25V20.h:151
Spi1Send
signed short Spi1Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 1.
Definition: spi1.c:151
FM25V20_WorkingMode
Definition: FM25V20.h:163

Here is the call graph for this function:

Here is the caller graph for this function:

void FM25V20Init | ( | void |  | ) |

Function used to initialize the FM25V20 memory.

Definition at line 67 of file FM25V20.c.

References tFM25V20StatusReg::bits, tFM25V20StatusReg::BP0, tFM25V20StatusReg::BP1, FM25V20_CS_MASK, FM25V20_CS_SHIFT, FM25V20_HOLD_MASK, FM25V20_HOLD_SHIFT, FM25V20_Lpm, FM25V20_SPI_BAUDRATE, FM25V20_WorkingMode, FM25V20_WP_MASK, FM25V20_WP_SHIFT, FM25V20SetStatusReg(), Spi1Enable, Spi1Init(), and tFM25V20StatusReg::WPEN.

Referenced by MemoryManagerInit().

67 {
68
69 FM25V20_Lpm = FM25V20_WorkingMode;
70
71 /*-- Configure Clock for general IO --*/
72 SIM->SCGC5 |= SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTB_MASK;
73
74 /*-- Configure CS --*/
75 PTD->PDDR |= GPIO_PDDR_PDD(FM25V20_CS_MASK); //As output
76 PTD->PCOR |= FM25V20_CS_MASK; //Default state is off
77 PORTD->PCR[FM25V20_CS_SHIFT] = PORT_PCR_MUX(0x01); //IO config
78
79 /*-- Configure WP --*/
80 PTB->PDDR |= GPIO_PDDR_PDD(FM25V20_WP_MASK); //As output
81 PTB->PCOR |= FM25V20_WP_MASK; //Default state is on
82 PORTB->PCR[FM25V20_WP_SHIFT] = PORT_PCR_MUX(0x01); //IO config
83
84 /*-- Configure HOLD --*/
85 PTB->PDDR |= GPIO_PDDR_PDD(FM25V20_HOLD_MASK); //As output
86 PTB->PSOR |= FM25V20_HOLD_MASK; //Default state is off
87 PORTB->PCR[FM25V20_HOLD_SHIFT] = PORT_PCR_MUX(0x01); //IO config
88
89 /*-- Initialize SPI --*/
90 Spi1Init(FM25V20_SPI_BAUDRATE);
91 Spi1Enable();
92
93 /*-- Initialize memory --*/
94 tFM25V20StatusReg statusReg;
95 statusReg.bits.BP0 = 0; //Disable block protection
96 statusReg.bits.BP1 = 0;
97 statusReg.bits.WPEN = 1; //Enable WP pin
98 FM25V20SetStatusReg(statusReg);
99
100 }
FM25V20_WP_SHIFT
#define FM25V20_WP_SHIFT
Define the IO mask and shift used by the FM25V20 driver.
Definition: FM25V20.h:41
FM25V20_WP_MASK
#define FM25V20_WP_MASK
Define the IO mask and shift used by the FM25V20 driver.
Definition: FM25V20.h:42
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_MASK
#define FM25V20_CS_MASK
Define the IO mask and shift used by the FM25V20 driver.
Definition: FM25V20.h:38
FM25V20_HOLD_MASK
#define FM25V20_HOLD_MASK
Define the IO mask and shift used by the FM25V20 driver.
Definition: FM25V20.h:46
FM25V20_HOLD_SHIFT
#define FM25V20_HOLD_SHIFT
Define the IO mask and shift used by the FM25V20 driver.
Definition: FM25V20.h:45
tFM25V20StatusReg::BP1
unsigned char BP1
Definition: FM25V20.h:137
FM25V20SetStatusReg
void FM25V20SetStatusReg(tFM25V20StatusReg status)
Definition: FM25V20.c:160
tFM25V20StatusReg::bits
struct tFM25V20StatusReg::@16 bits
Spi1Enable
#define Spi1Enable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:132
Spi1Init
void Spi1Init(unsigned long sclkFreq)
Function used to initialize the SPI1 module.
Definition: spi1.c:80
tFM25V20StatusReg::WPEN
unsigned char WPEN
Definition: FM25V20.h:139
FM25V20_SPI_BAUDRATE
#define FM25V20_SPI_BAUDRATE
Define the baudrate used by the communication interface with the FM25V20.
Definition: FM25V20.h:57
FM25V20_CS_SHIFT
#define FM25V20_CS_SHIFT
Define the IO mask and shift used by the FM25V20 driver.
Definition: FM25V20.h:37
tFM25V20StatusReg
structure used to read and get the status register of the device.
Definition: FM25V20.h:132
tFM25V20StatusReg::BP0
unsigned char BP0
Definition: FM25V20.h:136
FM25V20_WorkingMode
Definition: FM25V20.h:163

Here is the call graph for this function:

Here is the caller graph for this function:

tFM25V20_LPMState FM25V20IsInLowPower | ( | void |  | ) |

Get the low power status of the memory.

Returns
  (tFM25V20_LPMState) : return the actual power state of the memory.

Definition at line 244 of file FM25V20.c.

References FM25V20_Lpm.

Referenced by MemoryManagerClearLog(), MemoryManagerComputeNbrLog(), MemoryManagerReadDiving(), MemoryManagerReadLog(), MemoryManagerReadSerial(), MemoryManagerWriteDiving(), MemoryManagerWriteLog(), and MemoryManagerWriteSerial().

244 {
245 return FM25V20_Lpm;
246 }
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43

Here is the caller graph for this function:

void FM25V20LPM | ( | void |  | ) |

Put the memory in a low power mode.

Definition at line 178 of file FM25V20.c.

References FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_LowPowerMode, FM25V20_Lpm, FM25V20_OPCODE_SLEEP, FM25V20_WorkingMode, Spi1GetEnable, and Spi1Send().

Referenced by MemoryManagerClearLog(), MemoryManagerComputeNbrLog(), MemoryManagerReadDiving(), MemoryManagerReadLog(), MemoryManagerReadSerial(), MemoryManagerWriteDiving(), MemoryManagerWriteLog(), MemoryManagerWriteSerial(), and PowerManagerEnterLPM().

178 {
179
180 if (Spi1GetEnable() && FM25V20_Lpm == FM25V20_WorkingMode) {
181 unsigned char data[] = { FM25V20_OPCODE_SLEEP };
182 FM25V20_CS_Enable();
183 Spi1Send(data, 1);
184 FM25V20_CS_Disable();
185 FM25V20_Lpm = FM25V20_LowPowerMode;
186 }
187 }
FM25V20_OPCODE_SLEEP
#define FM25V20_OPCODE_SLEEP
Define the memory opcode.
Definition: FM25V20.h:84
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
FM25V20_LowPowerMode
Definition: FM25V20.h:162
Spi1GetEnable
#define Spi1GetEnable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:134
Spi1Send
signed short Spi1Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 1.
Definition: spi1.c:151
FM25V20_WorkingMode
Definition: FM25V20.h:163

Here is the call graph for this function:

Here is the caller graph for this function:

signed char FM25V20ReadData | ( | unsigned long | addr,
|  | unsigned char | data[],
|  | unsigned long | dataLength
| ) |  |

Read data from the memory.

Parameters

  [in] | addr | (unsigned long) ; address in the memory where to read the data.
  [in] | data[] | (unsigned char[]) : pointer on the buffer where data readed will writed.
  [in] | dataLength | (unsigned long) : length of the data to read.

Returns
  (signed char) : 0 is the read operation is a success else return -1.

Definition at line 224 of file FM25V20.c.

References FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_Lpm, FM25V20_OPCODE_READ, FM25V20_WorkingMode, Spi1GetEnable, Spi1Read(), and Spi1Send().

Referenced by FM25V20MemTest_Clear(), FM25V20MemTest_HighFreqDown(), FM25V20MemTest_HighFreqUp(), FM25V20MemTest_PulseN(), FM25V20MemTest_PulseP(), FM25V20MemTest_Set(), MemoryManagerComputeNbrLog(), MemoryManagerReadDiving(), MemoryManagerReadLog(), and MemoryManagerReadSerial().

224 {
225
226 if (Spi1GetEnable() && FM25V20_Lpm == FM25V20_WorkingMode) {
227
228 unsigned char dataPreambule[4];
229 dataPreambule[0] = FM25V20_OPCODE_READ;
230 dataPreambule[1] = (unsigned char) ((addr >> 16) & 0x3);
231 dataPreambule[2] = (unsigned char) ((addr >> 8) & 0xFF);
232 dataPreambule[3] = (unsigned char) (addr & 0xFF);
233 FM25V20_CS_Enable();
234 Spi1Send(dataPreambule, 4); //Send preambule
235 Spi1Read(data, dataLength); //Send data
236 FM25V20_CS_Disable();
237 return 0;
238
239 } else {
240 return -1;
241 }
242 }
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_OPCODE_READ
#define FM25V20_OPCODE_READ
Define the memory opcode.
Definition: FM25V20.h:81
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
Spi1GetEnable
#define Spi1GetEnable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:134
Spi1Read
signed short Spi1Read(unsigned char *data, unsigned short dataLength)
Function used to read data over the SPI module 1.
Definition: spi1.c:187
Spi1Send
signed short Spi1Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 1.
Definition: spi1.c:151
FM25V20_WorkingMode
Definition: FM25V20.h:163

Here is the call graph for this function:

Here is the caller graph for this function:

signed char FM25V20ReadDeviceId | ( | unsigned char | deviceId[FM25V20_DEVICE_ID_BYTE_SIZE] | ) |

Function used to read the device ID.

Parameters

  [out] | deviceId[FM25V20_DEVICE_ID_BYTE_SIZE] | (unsigned char[FM25V20_DEVICE_ID_BYTE_SIZE]) : pointer on the tab where the data will be stored.

Definition at line 142 of file FM25V20.c.

References FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_Lpm, FM25V20_OPCODE_RDID, FM25V20_WorkingMode, Spi1GetEnable, Spi1Read(), and Spi1Send().

143 {
144
145 if (Spi1GetEnable() && FM25V20_Lpm == FM25V20_WorkingMode) {
146
147 unsigned char data[1] = { FM25V20_OPCODE_RDID };
148
149 FM25V20_CS_Enable();
150 Spi1Send(data, 1);
151 Spi1Read(deviceId, FM25V20_DEVICE_ID_BYTE_SIZE);
152 FM25V20_CS_Disable();
153
154 return 0;
155 } else {
156 return -1; //SPI isn't enable
157 }
158 }
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
Spi1GetEnable
#define Spi1GetEnable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:134
FM25V20_OPCODE_RDID
#define FM25V20_OPCODE_RDID
Define the memory opcode.
Definition: FM25V20.h:85
Spi1Read
signed short Spi1Read(unsigned char *data, unsigned short dataLength)
Function used to read data over the SPI module 1.
Definition: spi1.c:187
FM25V20_DEVICE_ID_BYTE_SIZE
#define FM25V20_DEVICE_ID_BYTE_SIZE
Define the size of the device ID returned by the RDID opcode.
Definition: FM25V20.h:93
Spi1Send
signed short Spi1Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 1.
Definition: spi1.c:151
FM25V20_WorkingMode
Definition: FM25V20.h:163

Here is the call graph for this function:

tFM25V20StatusReg FM25V20ReadStatusReg | ( | void |  | ) |

Functions used to set and read the status register.

Definition at line 122 of file FM25V20.c.

References tFM25V20StatusReg::all, FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_Lpm, FM25V20_OPCODE_RDSR, FM25V20_WorkingMode, Spi1GetEnable, Spi1Read(), and Spi1Send().

122 {
123 tFM25V20StatusReg status;
124
125 if (Spi1GetEnable() && FM25V20_Lpm == FM25V20_WorkingMode) {
126
127 unsigned char data[1] = { FM25V20_OPCODE_RDSR };
128
129 FM25V20_CS_Enable();
130 Spi1Send(data, 1);
131 Spi1Read((unsigned char*) &status, 1);
132 FM25V20_CS_Disable();
133
134 } else {
135 status.all = 0xFF; //SPI is not enable -> return an absurb value
136 }
137
138 return status;
139
140 }
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
Spi1GetEnable
#define Spi1GetEnable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:134
tFM25V20StatusReg::all
unsigned char all
Definition: FM25V20.h:141
FM25V20_OPCODE_RDSR
#define FM25V20_OPCODE_RDSR
Define the memory opcode.
Definition: FM25V20.h:79
Spi1Read
signed short Spi1Read(unsigned char *data, unsigned short dataLength)
Function used to read data over the SPI module 1.
Definition: spi1.c:187
tFM25V20StatusReg
structure used to read and get the status register of the device.
Definition: FM25V20.h:132
Spi1Send
signed short Spi1Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 1.
Definition: spi1.c:151
FM25V20_WorkingMode
Definition: FM25V20.h:163

Here is the call graph for this function:

void FM25V20SetStatusReg | ( | tFM25V20StatusReg | status | ) |

Functions used to set and read the status register.

Definition at line 160 of file FM25V20.c.

References tFM25V20StatusReg::all, FM25V20_ALLOW_WRITE, FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_FORBIDDEN_WRITE, FM25V20_Lpm, FM25V20_OPCODE_WRSR, FM25V20_SetWriteEnable(), FM25V20_SetWriteProtect, FM25V20_WorkingMode, FM25V20_WP_OFF, FM25V20_WP_ON, Spi1GetEnable, and Spi1Send().

Referenced by FM25V20Init().

160 {
161
162 if (Spi1GetEnable() && FM25V20_Lpm == FM25V20_WorkingMode) {
163
164 FM25V20_SetWriteProtect(FM25V20_WP_OFF); //Disable Write Protect
165 FM25V20_SetWriteEnable(FM25V20_ALLOW_WRITE); //Allow device write
166
167 unsigned char data[] = { FM25V20_OPCODE_WRSR, status.all };
168
169 FM25V20_CS_Enable();
170 Spi1Send(data, 2);
171 FM25V20_CS_Disable();
172
173 FM25V20_SetWriteProtect(FM25V20_WP_ON); //Enable Write Protect
174 FM25V20_SetWriteEnable(FM25V20_FORBIDDEN_WRITE); //Disable write
175 }
176 }
FM25V20_SetWriteProtect
#define FM25V20_SetWriteProtect(FM25V20_WriteProtectState)
Macro used to set the write protect state.
Definition: FM25V20.h:198
FM25V20_WP_ON
Definition: FM25V20.h:122
FM25V20_WP_OFF
Definition: FM25V20.h:123
FM25V20_FORBIDDEN_WRITE
Definition: FM25V20.h:152
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
FM25V20_OPCODE_WRSR
#define FM25V20_OPCODE_WRSR
Define the memory opcode.
Definition: FM25V20.h:80
Spi1GetEnable
#define Spi1GetEnable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:134
tFM25V20StatusReg::all
unsigned char all
Definition: FM25V20.h:141
FM25V20_ALLOW_WRITE
Definition: FM25V20.h:151
Spi1Send
signed short Spi1Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 1.
Definition: spi1.c:151
FM25V20_WorkingMode
Definition: FM25V20.h:163
FM25V20_SetWriteEnable
void FM25V20_SetWriteEnable(tFM25V20_AllowWrite allowWrite)
Function used to set the write mode.
Definition: FM25V20.c:102

Here is the call graph for this function:

Here is the caller graph for this function:

void FM25V20WakeUp | ( | void |  | ) |

Wake up the memory from the low power mode.

Definition at line 189 of file FM25V20.c.

References FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_Lpm, and FM25V20_WorkingMode.

Referenced by MemoryManagerClearLog(), MemoryManagerComputeNbrLog(), MemoryManagerReadDiving(), MemoryManagerReadLog(), MemoryManagerReadSerial(), MemoryManagerWriteDiving(), MemoryManagerWriteLog(), and MemoryManagerWriteSerial().

189 {
190 FM25V20_CS_Enable();
191 unsigned long countDown = 1000;
192 while (countDown--);
193 FM25V20_CS_Disable();
194 countDown = 2000;
195 while(countDown--);
196 FM25V20_Lpm = FM25V20_WorkingMode;
197 }
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
FM25V20_WorkingMode
Definition: FM25V20.h:163

Here is the caller graph for this function:

signed char FM25V20WriteData | ( | unsigned long | addr,
|  | unsigned char | data[],
|  | unsigned long | dataLength
| ) |  |

Write data to the memory.

Parameters

  [in] | addr | (unsigned long) ; address in the memory where to write the data.
  [in] | data[] | (unsigned char[]) : pointer on the data to write in memory.
  [in] | dataLength | (unsigned long) : length of the data to write.

Returns
  (signed char) : 0 is the write operation is a success else return -1.

Definition at line 199 of file FM25V20.c.

References FM25V20_ALLOW_WRITE, FM25V20_CS_Disable, FM25V20_CS_Enable, FM25V20_FORBIDDEN_WRITE, FM25V20_Lpm, FM25V20_OPCODE_WRITE, FM25V20_SetWriteEnable(), FM25V20_SetWriteProtect, FM25V20_WorkingMode, FM25V20_WP_OFF, FM25V20_WP_ON, Spi1GetEnable, and Spi1Send().

Referenced by FM25V20MemTest_Clear(), FM25V20MemTest_HighFreqDown(), FM25V20MemTest_HighFreqUp(), FM25V20MemTest_PulseN(), FM25V20MemTest_PulseP(), FM25V20MemTest_Set(), MemoryManagerClearLog(), MemoryManagerWriteDiving(), MemoryManagerWriteLog(), and MemoryManagerWriteSerial().

199 {
200
201 if (Spi1GetEnable() && FM25V20_Lpm == FM25V20_WorkingMode) {
202
203 FM25V20_SetWriteProtect(FM25V20_WP_OFF); //Disable Write Protect
204 FM25V20_SetWriteEnable(FM25V20_ALLOW_WRITE); //Allow device write
205
206 unsigned char dataPreambule[4];
207 dataPreambule[0] = FM25V20_OPCODE_WRITE;
208 dataPreambule[1] = ((unsigned char) (addr >> 16) & 0x03);
209 dataPreambule[2] = ((unsigned char) (addr >> 8) & 0xFF);
210 dataPreambule[3] = (unsigned char) (addr & 0xFF);
211 FM25V20_CS_Enable();
212 Spi1Send(dataPreambule, 4); //Send preambule
213 Spi1Send(data, dataLength); //Send data
214 FM25V20_CS_Disable();
215
216 FM25V20_SetWriteProtect(FM25V20_WP_ON); //Enable Write Protect
217 FM25V20_SetWriteEnable(FM25V20_FORBIDDEN_WRITE); //Disable write
218 return 0;
219 } else {
220 return -1;
221 }
222 }
FM25V20_SetWriteProtect
#define FM25V20_SetWriteProtect(FM25V20_WriteProtectState)
Macro used to set the write protect state.
Definition: FM25V20.h:198
FM25V20_WP_ON
Definition: FM25V20.h:122
FM25V20_WP_OFF
Definition: FM25V20.h:123
FM25V20_FORBIDDEN_WRITE
Definition: FM25V20.h:152
FM25V20_Lpm
tFM25V20_LPMState FM25V20_Lpm
Definition: FM25V20.c:43
FM25V20_CS_Disable
#define FM25V20_CS_Disable()
Definition: FM25V20.c:26
FM25V20_OPCODE_WRITE
#define FM25V20_OPCODE_WRITE
Define the memory opcode.
Definition: FM25V20.h:83
FM25V20_CS_Enable
#define FM25V20_CS_Enable()
Definition: FM25V20.c:25
Spi1GetEnable
#define Spi1GetEnable()
Set/Clear/Read the SPI enable status.
Definition: spi1.h:134
FM25V20_ALLOW_WRITE
Definition: FM25V20.h:151
Spi1Send
signed short Spi1Send(unsigned char *data, unsigned short dataLength)
Function used to send data over the SPI module 1.
Definition: spi1.c:151
FM25V20_WorkingMode
Definition: FM25V20.h:163
FM25V20_SetWriteEnable
void FM25V20_SetWriteEnable(tFM25V20_AllowWrite allowWrite)
Function used to set the write mode.
Definition: FM25V20.c:102

Here is the call graph for this function:

Here is the caller graph for this function: