Kinetis SDK v.2.0 API Reference Manual  Rev. 0
Freescale Semiconductor, Inc.
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
FlexBus: External Bus Interface Driver

Overview

The KSDK provides a peripheral driver for the Crossbar External Bus Interface (FlexBus) block of Kinetis devices.

Overview

A multifunction external bus interface is provided on the device with a basic functionality to interface to slave-only devices. It can be directly connected to the following asynchronous or synchronous devices with little or no additional circuitry:

For asynchronous devices, a simple chip-select based interface can be used. The FlexBus interface has up to six general purpose chip-selects, FB_CS[5:0]. The actual number of chip selects available depends upon the device and its pin configuration.

FlexBus functional operation

To configure the FlexBus driver, use on of the two ways to configure the flexbus_config_t structure.

  1. Using the FLEXBUS_GetDefaultConfig() function.
  2. Set parameters in the flexbus_config_t structure.

To initialize and configure the FlexBus driver, call the FLEXBUS_Init() function and pass a pointer to the flexbus_config_t structure.

To De-initialize the FlexBus driver, call the FLEXBUS_Deinit() function.

Typical use case and example

This example shows how to write/read to external memory (MRAM) by using the FlexBus module.

flexbus_config_t flexbusUserConfig;
FLEXBUS_GetDefaultConfig(&flexbusUserConfig); /* Gets the default configuration.
/* Configure some parameters when using MRAM
flexbusUserConfig.waitStates = 2U; /* Wait 2 states
flexbusUserConfig.chipBaseAddress = MRAM_START_ADDRESS; /* MRAM address for using FlexBus
flexbusUserConfig.chipBaseAddressMask = 7U; /* 512 kilobytes memory size
FLEXBUS_Init(FB, &flexbusUserConfig); /* Initializes and configures the FlexBus module
/* Do something
FLEXBUS_Deinit(FB);

Files

file  fsl_flexbus.h
 

Data Structures

struct  flexbus_config_t
 Configuration structure that the user needs to set. More...
 

Enumerations

enum  flexbus_port_size_t {
  kFLEXBUS_4Bytes = 0x00U,
  kFLEXBUS_1Byte = 0x01U,
  kFLEXBUS_2Bytes = 0x02U
}
 Defines port size for FlexBus peripheral. More...
 
enum  flexbus_write_address_hold_t {
  kFLEXBUS_Hold1Cycle = 0x00U,
  kFLEXBUS_Hold2Cycles = 0x01U,
  kFLEXBUS_Hold3Cycles = 0x02U,
  kFLEXBUS_Hold4Cycles = 0x03U
}
 Defines number of cycles to hold address and attributes for FlexBus peripheral. More...
 
enum  flexbus_read_address_hold_t {
  kFLEXBUS_Hold1Or0Cycles = 0x00U,
  kFLEXBUS_Hold2Or1Cycles = 0x01U,
  kFLEXBUS_Hold3Or2Cycle = 0x02U,
  kFLEXBUS_Hold4Or3Cycle = 0x03U
}
 Defines number of cycles to hold address and attributes for FlexBus peripheral. More...
 
enum  flexbus_address_setup_t {
  kFLEXBUS_FirstRisingEdge = 0x00U,
  kFLEXBUS_SecondRisingEdge = 0x01U,
  kFLEXBUS_ThirdRisingEdge = 0x02U,
  kFLEXBUS_FourthRisingEdge = 0x03U
}
 Address setup for FlexBus peripheral. More...
 
enum  flexbus_bytelane_shift_t {
  kFLEXBUS_NotShifted = 0x00U,
  kFLEXBUS_Shifted = 0x01U
}
 Defines byte-lane shift for FlexBus peripheral. More...
 
enum  flexbus_multiplex_group1_t {
  kFLEXBUS_MultiplexGroup1_FB_ALE = 0x00U,
  kFLEXBUS_MultiplexGroup1_FB_CS1 = 0x01U,
  kFLEXBUS_MultiplexGroup1_FB_TS = 0x02U
}
 Defines multiplex group1 valid signals. More...
 
enum  flexbus_multiplex_group2_t {
  kFLEXBUS_MultiplexGroup2_FB_CS4 = 0x00U,
  kFLEXBUS_MultiplexGroup2_FB_TSIZ0 = 0x01U,
  kFLEXBUS_MultiplexGroup2_FB_BE_31_24 = 0x02U
}
 Defines multiplex group2 valid signals. More...
 
enum  flexbus_multiplex_group3_t {
  kFLEXBUS_MultiplexGroup3_FB_CS5 = 0x00U,
  kFLEXBUS_MultiplexGroup3_FB_TSIZ1 = 0x01U,
  kFLEXBUS_MultiplexGroup3_FB_BE_23_16 = 0x02U
}
 Defines multiplex group3 valid signals. More...
 
enum  flexbus_multiplex_group4_t {
  kFLEXBUS_MultiplexGroup4_FB_TBST = 0x00U,
  kFLEXBUS_MultiplexGroup4_FB_CS2 = 0x01U,
  kFLEXBUS_MultiplexGroup4_FB_BE_15_8 = 0x02U
}
 Defines multiplex group4 valid signals. More...
 
enum  flexbus_multiplex_group5_t {
  kFLEXBUS_MultiplexGroup5_FB_TA = 0x00U,
  kFLEXBUS_MultiplexGroup5_FB_CS3 = 0x01U,
  kFLEXBUS_MultiplexGroup5_FB_BE_7_0 = 0x02U
}
 Defines multiplex group5 valid signals. More...
 

Driver version

#define FSL_FLEXBUS_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))
 Version 2.0.0. More...
 

FlexBus functional operation

void FLEXBUS_Init (FB_Type *base, const flexbus_config_t *config)
 Initializes and configures the FlexBus module. More...
 
void FLEXBUS_Deinit (FB_Type *base)
 De-initializes a FlexBus instance. More...
 
void FLEXBUS_GetDefaultConfig (flexbus_config_t *config)
 Initializes the FlexBus configuration structure. More...
 

Data Structure Documentation

struct flexbus_config_t

Data Fields

uint8_t chip
 Chip FlexBus for validation.
 
uint8_t waitStates
 Value of wait states.
 
uint32_t chipBaseAddress
 Chip base address for using FlexBus.
 
uint32_t chipBaseAddressMask
 Chip base address mask.
 
bool writeProtect
 Write protected.
 
bool burstWrite
 Burst-Write enable.
 
bool burstRead
 Burst-Read enable.
 
bool byteEnableMode
 Byte-enable mode support.
 
bool autoAcknowledge
 Auto acknowledge setting.
 
bool extendTransferAddress
 Extend transfer start/extend address latch enable.
 
bool secondaryWaitStates
 Secondary wait states number.
 
flexbus_port_size_t portSize
 Port size of transfer.
 
flexbus_bytelane_shift_t byteLaneShift
 Byte-lane shift enable.
 
flexbus_write_address_hold_t writeAddressHold
 Write address hold or deselect option.
 
flexbus_read_address_hold_t readAddressHold
 Read address hold or deselect option.
 
flexbus_address_setup_t addressSetup
 Address setup setting.
 
flexbus_multiplex_group1_t group1MultiplexControl
 FlexBus Signal Group 1 Multiplex control.
 
flexbus_multiplex_group2_t group2MultiplexControl
 FlexBus Signal Group 2 Multiplex control.
 
flexbus_multiplex_group3_t group3MultiplexControl
 FlexBus Signal Group 3 Multiplex control.
 
flexbus_multiplex_group4_t group4MultiplexControl
 FlexBus Signal Group 4 Multiplex control.
 
flexbus_multiplex_group5_t group5MultiplexControl
 FlexBus Signal Group 5 Multiplex control.
 

Macro Definition Documentation

#define FSL_FLEXBUS_DRIVER_VERSION   (MAKE_VERSION(2, 0, 0))

Enumeration Type Documentation

Enumerator
kFLEXBUS_4Bytes 

32-bit port size

kFLEXBUS_1Byte 

8-bit port size

kFLEXBUS_2Bytes 

16-bit port size

Enumerator
kFLEXBUS_Hold1Cycle 

Hold address and attributes one cycles after FB_CSn negates on writes.

kFLEXBUS_Hold2Cycles 

Hold address and attributes two cycles after FB_CSn negates on writes.

kFLEXBUS_Hold3Cycles 

Hold address and attributes three cycles after FB_CSn negates on writes.

kFLEXBUS_Hold4Cycles 

Hold address and attributes four cycles after FB_CSn negates on writes.

Enumerator
kFLEXBUS_Hold1Or0Cycles 

Hold address and attributes 1 or 0 cycles on reads.

kFLEXBUS_Hold2Or1Cycles 

Hold address and attributes 2 or 1 cycles on reads.

kFLEXBUS_Hold3Or2Cycle 

Hold address and attributes 3 or 2 cycles on reads.

kFLEXBUS_Hold4Or3Cycle 

Hold address and attributes 4 or 3 cycles on reads.

Enumerator
kFLEXBUS_FirstRisingEdge 

Assert FB_CSn on first rising clock edge after address is asserted.

kFLEXBUS_SecondRisingEdge 

Assert FB_CSn on second rising clock edge after address is asserted.

kFLEXBUS_ThirdRisingEdge 

Assert FB_CSn on third rising clock edge after address is asserted.

kFLEXBUS_FourthRisingEdge 

Assert FB_CSn on fourth rising clock edge after address is asserted.

Enumerator
kFLEXBUS_NotShifted 

Not shifted.

Data is left-justified on FB_AD

kFLEXBUS_Shifted 

Shifted.

Data is right justified on FB_AD

Enumerator
kFLEXBUS_MultiplexGroup1_FB_ALE 

FB_ALE.

kFLEXBUS_MultiplexGroup1_FB_CS1 

FB_CS1.

kFLEXBUS_MultiplexGroup1_FB_TS 

FB_TS.

Enumerator
kFLEXBUS_MultiplexGroup2_FB_CS4 

FB_CS4.

kFLEXBUS_MultiplexGroup2_FB_TSIZ0 

FB_TSIZ0.

kFLEXBUS_MultiplexGroup2_FB_BE_31_24 

FB_BE_31_24.

Enumerator
kFLEXBUS_MultiplexGroup3_FB_CS5 

FB_CS5.

kFLEXBUS_MultiplexGroup3_FB_TSIZ1 

FB_TSIZ1.

kFLEXBUS_MultiplexGroup3_FB_BE_23_16 

FB_BE_23_16.

Enumerator
kFLEXBUS_MultiplexGroup4_FB_TBST 

FB_TBST.

kFLEXBUS_MultiplexGroup4_FB_CS2 

FB_CS2.

kFLEXBUS_MultiplexGroup4_FB_BE_15_8 

FB_BE_15_8.

Enumerator
kFLEXBUS_MultiplexGroup5_FB_TA 

FB_TA.

kFLEXBUS_MultiplexGroup5_FB_CS3 

FB_CS3.

kFLEXBUS_MultiplexGroup5_FB_BE_7_0 

FB_BE_7_0.

Function Documentation

void FLEXBUS_Init ( FB_Type *  base,
const flexbus_config_t config 
)

This function enables the clock gate for FlexBus module. Only chip 0 is validated and set to known values. Other chips are disabled. NOTE: In this function, certain parameters, depending on external memories, must be set before using FLEXBUS_Init() function. This example shows how to set up the uart_state_t and the flexbus_config_t parameters and how to call the FLEXBUS_Init function by passing in these parameters:

flexbus_config_t flexbusConfig;
FLEXBUS_GetDefaultConfig(&flexbusConfig);
flexbusConfig.waitStates = 2U;
flexbusConfig.chipBaseAddress = 0x60000000U;
flexbusConfig.chipBaseAddressMask = 7U;
FLEXBUS_Init(FB, &flexbusConfig);
Parameters
baseFlexBus peripheral address.
configPointer to the configure structure
void FLEXBUS_Deinit ( FB_Type *  base)

This function disables the clock gate of the FlexBus module clock.

Parameters
baseFlexBus peripheral address.
void FLEXBUS_GetDefaultConfig ( flexbus_config_t config)

This function initializes the FlexBus configuration structure to default value. The default values are:

fbConfig->chip = 0;
fbConfig->writeProtect = 0;
fbConfig->burstWrite = 0;
fbConfig->burstRead = 0;
fbConfig->byteEnableMode = 0;
fbConfig->autoAcknowledge = true;
fbConfig->extendTransferAddress = 0;
fbConfig->secondaryWaitStates = 0;
fbConfig->byteLaneShift = kFLEXBUS_NotShifted;
fbConfig->writeAddressHold = kFLEXBUS_Hold1Cycle;
fbConfig->readAddressHold = kFLEXBUS_Hold1Or0Cycles;
fbConfig->addressSetup = kFLEXBUS_FirstRisingEdge;
fbConfig->portSize = kFLEXBUS_1Byte;
fbConfig->group1MultiplexControl = kFLEXBUS_MultiplexGroup1_FB_ALE;
fbConfig->group2MultiplexControl = kFLEXBUS_MultiplexGroup2_FB_CS4 ;
fbConfig->group3MultiplexControl = kFLEXBUS_MultiplexGroup3_FB_CS5;
fbConfig->group4MultiplexControl = kFLEXBUS_MultiplexGroup4_FB_TBST;
fbConfig->group5MultiplexControl = kFLEXBUS_MultiplexGroup5_FB_TA;
Parameters
configPointer to the initialization structure.
See Also
FLEXBUS_Init