We are using the Toradex CE libraries for converting the tegra T30 (X1 module connector) pins to GMI registers and use those to write/read data from an external board. We are using version 1.1 of the library. So far it had been working great for us, but recently we started seeing data corruptions on the bus. Below is a code snippet to show how we were using the library:
#include "Toradex_Includes\headers\coproclib.h"
#include "Toradex_Includes\headers\MapReglib.h"
#include "Toradex_Includes\headers\gpiolib.h"
#include "Toradex_Includes\headers\clklib.h"
#include "Toradex_Includes\headers\TegraT30.h"
Setup()
{
ClkLibInit();
ClkLibSetClockFrequency(SLINK_SPI4_CLK_TEG, 101000, 103000, ClockOptimiseForPrecision);
ClkLibSetClockFrequency(SNOR_CLK_TEG, 101000, 103000, tClockOptimise::ClockOptimiseForPrecision);
WORD* dataRegister = (WORD*)MapMemory(T30_SNOR_ADDR, TEST_DATA_SIZE);
GMI_REGISTERS* gmiRegisters = (GMI_REGISTERS*)MapRegister(GMI_CONF_BASE);
InitGPIOLib();
for (DWORD pin : listOfPins)
{
PIN_INSTANCE pinInst;
GetGPIOFromPin(pin, FALSE, &pinInst);
SetGPIOAltFn(pinInst.inst1, 2, DIR_IN); // AltFn always 2
TegraSetPullStatePinGroup(pinInst.inst1, 0); //Pull state: nothing (normal)
TegraSetTristatePinGroup(pinInst.inst1, 0); //Tristate: no
}
gmiRegisters->SNOR_CONFIG_0 = MST_ENB_ENABLE | NMUX_ASYNC_IO_ENABLE | SNOR_SEL_CS2;
}
writeData(addressOffset , valueToWrite_16Bit)
{
gmiRegisters->SNOR_CONFIG_0 |= GO_NOR_ENABLE;
*(dataRegister + addressOffset) = valueToWrite_16Bit;
gmiRegisters->SNOR_CONFIG_0 &= ~GO_NOR_ENABLE;
}
readData(addressOffset , valueToRead_16Bit)
{
gmiRegisters->SNOR_CONFIG_0 |= GO_NOR_ENABLE;
valueToRead_16Bit = *(dataRegister + addressOffset);
gmiRegisters->SNOR_CONFIG_0 &= ~GO_NOR_ENABLE;
}
Once the data corruption started happening I started digging deeper and realized these libraries are obsolete now. Version 2.3 is the latest release and we are using 1.1. Looking at the release notes nothing pointed towards an explanation of the data corruption but I would like to upgrade to the new libraries anyway.
The problem is the libraries are not backwards compatible and I am having a hard time finding the replacement functions/enums for my existing code. I was able to figure out how to setup the Alt functions using the new gpio_teg.h file:
//******************************************************************************
/// Get the Alternative function setting of the specified SODIMM pin number or GPIO number or Apalis pin number
/// @param[in] hGpio HANDLE received from TegGpio_Init()
/// @param[in] io GPIO number or SODIMM pin number or Apalis pin number
/// @return Alternative function setting number
tIoAltFn TegGpio_GetAltFn(HANDLE hGpio, uIo io);
//******************************************************************************
/// Set the Alternative function setting of the specified io
/// @param[in] hGpio HANDLE received from TegGpio_Init()
/// @param[in] io GPIO or Colibri pin or Apalis pin number in uIo format
/// @param[in] altFn Alternative function setting, (tIoAltFn)use -1 to configure as GPIO.
void TegGpio_SetAltFn(HANDLE hGpio, uIo io, tIoAltFn altFn);
But I am not sure where to look for GMI related functions which used to exist in the MapRegLib.h e.g. :
//******************************************************************************
/// Map Registers at a physical address (map areas up to the PAGE_SIZE).
/// @param[in] pa Physical address
/// @retval Virtual address
void *MapRegister(DWORD pa);
//******************************************************************************
/// Same as MapRegister() but can also map larger sections
/// @param[in] pa Physical address.
/// @param[in] size Size to map in bytes.
/// @retval Virtual address
void *MapMemory(DWORD pa, DWORD size);
Also some of the parameters used in the code snippet (e.g. GMI_CONF_BASE, T30_MIO_ADDR, GMI_REGISTERS struct etc.) are from the TegraT30.h file. This file was not part of the new library. I am not sure where to find the latest version of this file.
Thank you for your time.