ADI iSensor FX3 Firmware  v2.9.4-pub
Firmware for the Analog Devices EVAL-ADIS-FX3 IMU Evaluation Platform. This firmware can be compiled using the Cypress EZ USB Suite IDE
Functions | Variables
Flash.c File Reference

FX3 I2C EEPROM (model m24m02-dr) interfacing module. More...

#include "Flash.h"

Functions

static uint16_t GetFlashDeviceAddress (uint32_t ByteAddress)
 Gets the flash devices address, based on the requested byte address. More...
 
static CyU3PReturnStatus_t FlashTransfer (uint32_t Address, uint16_t NumBytes, uint8_t *Buf, CyBool_t isRead)
 Performs a transfer from the I2C flash memory. More...
 
CyU3PReturnStatus_t AdiFlashInit ()
 Initializes flash memory interface module. More...
 
void AdiFlashDeInit ()
 De-init the flash memory interfacing module. More...
 
void AdiFlashWrite (uint32_t Address, uint16_t NumBytes, uint8_t *WriteBuf)
 Write a block of memory to flash, at the specified byte address. More...
 
void AdiFlashRead (uint32_t Address, uint16_t NumBytes, uint8_t *ReadBuf)
 Read a block of memory from flash, at the specified byte address. More...
 
void AdiFlashReadHandler (uint32_t Address, uint16_t NumBytes)
 Handles flash read requests from control endpoint. More...
 

Variables

uint8_t USBBuffer [4096]
 
BoardState FX3State
 
static CyU3PDmaChannel flashTxHandle
 
static CyU3PDmaChannel flashRxHandle
 

Detailed Description

FX3 I2C EEPROM (model m24m02-dr) interfacing module.

Copyright (c) 2018-2020 Analog Devices, Inc. All Rights Reserved. This software is proprietary to Analog Devices, Inc. and its licensors.

THIS SOFTWARE UTILIZES LIBRARIES DEVELOPED AND MAINTAINED BY CYPRESS INC. THE LICENSE INCLUDED IN THIS REPOSITORY DOES NOT EXTEND TO CYPRESS PROPERTY.

Use of this file is governed by the license agreement included in this repository.

Date
04/30/2020
Author
A. Nolan (alex..nosp@m.nola.nosp@m.n@ana.nosp@m.log..nosp@m.com)

Function Documentation

◆ AdiFlashDeInit()

void AdiFlashDeInit ( )

De-init the flash memory interfacing module.

Returns
void

This functions destroys the DMA channels used for interfacing with the I2C module, and re-inits the I2C controller to operate in register mode, with the previously selected bitrate.

◆ AdiFlashInit()

CyU3PReturnStatus_t AdiFlashInit ( )

Initializes flash memory interface module.

Returns
Status code indication the success of the flash init operation

The FX3 board features a ST m24m02-dr I2C EEPROM. This function initializes the FX3 I2C block to operate in DMA mode with the max supported I2C clock. It then configures the I2C Rx and Tx channels to perform a transfer

◆ AdiFlashRead()

void AdiFlashRead ( uint32_t  Address,
uint16_t  NumBytes,
uint8_t *  ReadBuf 
)

Read a block of memory from flash, at the specified byte address.

Parameters
AddressThe start address (in flash) to perform the read operation from
NumBytesThe number of bytes to read from the flash
ReadBufRAM buffer to read flash data into
Returns
void

This function leaves the I2C EEPROM write functionality disabled. This prevents inadvertent writes from being processed.

◆ AdiFlashReadHandler()

void AdiFlashReadHandler ( uint32_t  Address,
uint16_t  NumBytes 
)

Handles flash read requests from control endpoint.

Parameters
AddressThe byte address in flash to start reading at
NumBytesThe number of bytes to read. Max 4KB
Returns
void

The data read from flash is returned over the control endpoint. This limits a single read to 4KB. If greater than a 4KB read is needed, multiple transactions should be sent. Managing this limit is left to the higher level software sending USB commands.

◆ AdiFlashWrite()

void AdiFlashWrite ( uint32_t  Address,
uint16_t  NumBytes,
uint8_t *  WriteBuf 
)

Write a block of memory to flash, at the specified byte address.

Parameters
AddressThe start address (in flash) to perform the write operation to
NumBytesThe number of bytes to write to flash
WriteBufRAM buffer containing data to be written to flash
Returns
void

This function controls the flash write enable signal. This write enable signal is used to prevent un-intended writes the flash from user space, via I2C functions. This write enable signal is only present on the iSensor FX3 board rev C or newer, but there shouldn't be any downside to asserting it on older hardware models.

◆ FlashTransfer()

static CyU3PReturnStatus_t FlashTransfer ( uint32_t  Address,
uint16_t  NumBytes,
uint8_t *  Buf,
CyBool_t  isRead 
)
static

Performs a transfer from the I2C flash memory.

Parameters
AddressThe flash byte address to start the read/write operation from. Valid range 0x0 - 0x40000
NumBytesThe number of data bytes to transfer to/from the flash
BufRAM data buffer. Write data must be placed here. Read data is returned here.
isReadBool indicating if operation is read or write
Returns
Status code indicating the success of the flash read/write operation

This function performs all interfacing with the ST m24m02-dr I2C EEPROM which is included on the iSensor FX3 board (and FX3 explorer kit). Before each transaction, AdiFlashInit is called to ensure the flash and DMA are configured properly. Then, for each transaction, the read/write is split into 64 byte (or less) chunks, which are each performed using a single I2C<->Mem DMA transfer. Once all required transfers have been performed, the flash is de-initialized.

◆ GetFlashDeviceAddress()

static uint16_t GetFlashDeviceAddress ( uint32_t  ByteAddress)
static

Gets the flash devices address, based on the requested byte address.

Returns
void The 8-bit flash device address

For the EEPROM, byte address bits 16-17 are encoded into the device address

Variable Documentation

◆ flashRxHandle

CyU3PDmaChannel flashRxHandle
static

I2C Rx DMA channel handle

◆ flashTxHandle

CyU3PDmaChannel flashTxHandle
static

I2C Tx DMA channel handle

◆ FX3State

BoardState FX3State
extern

FX3 state (from main)

Struct. which stores all run time configurable FX3 settings

◆ USBBuffer

uint8_t USBBuffer[4096]
extern

Global USB Buffer, from main