123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458 |
- //###########################################################################
- //
- // FILE: F2837xD_Emif.c
- //
- // TITLE: F2837xD EMIF Initialization & Support Functions.
- //
- //###########################################################################
- // $TI Release: F2837xD Support Library v3.05.00.00 $
- // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
- // $Copyright:
- // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
- //
- // Redistribution and use in source and binary forms, with or without
- // modification, are permitted provided that the following conditions
- // are met:
- //
- // Redistributions of source code must retain the above copyright
- // notice, this list of conditions and the following disclaimer.
- //
- // Redistributions in binary form must reproduce the above copyright
- // notice, this list of conditions and the following disclaimer in the
- // documentation and/or other materials provided with the
- // distribution.
- //
- // Neither the name of Texas Instruments Incorporated nor the names of
- // its contributors may be used to endorse or promote products derived
- // from this software without specific prior written permission.
- //
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- // $
- //###########################################################################
- //
- // Included Files
- //
- #include "F2837xD_device.h"
- #include "F2837xD_Examples.h"
- //
- // Emif1Initialize - This function initializes the EMIF1 to a known state.
- //
- void Emif1Initialize(void)
- {
- EALLOW;
- //
- // Perform a Module soft reset on EMIF
- //
- #ifdef CPU1
- DevCfgRegs.SOFTPRES1.all = 0x1;
- __asm (" nop");
- DevCfgRegs.SOFTPRES1.all = 0x0;
- #endif
- EDIS;
- }
- //
- // Emif2Initialize - This function initializes the EMIF2 to a known state.
- //
- void Emif2Initialize(void)
- {
- EALLOW;
- //
- // Perform a Module soft reset on EMIF
- //
- #ifdef CPU1
- DevCfgRegs.SOFTPRES1.all = 0x2;
- __asm (" nop");
- DevCfgRegs.SOFTPRES1.all = 0x0;
- #endif
- EDIS;
- }
- //
- // ASync_wait_config - Async wait configuration function
- //
- void ASync_wait_config(Uint16 inst, Uint16 wait_count, Uint16 wait_polarity)
- {
- if (inst == 0)
- {
- //
- // 7:0 Maximum Extended Wait cycles.
- //
- Emif1Regs.ASYNC_WCCR.bit.MAX_EXT_WAIT = wait_count;
- //
- // 28 Wait Polarity for pad_wait_i[0].
- //
- Emif1Regs.ASYNC_WCCR.bit.WP0 = wait_polarity;
- }
- else
- {
- //
- // 7:0 Maximum Extended Wait cycles.
- //
- Emif2Regs.ASYNC_WCCR.bit.MAX_EXT_WAIT = wait_count;
- //
- // 28 Wait Polarity for pad_wait_i[0].
- //
- Emif2Regs.ASYNC_WCCR.bit.WP0 = wait_polarity;
- }
- }
- //
- // ASync_cs2_config - Async CS2 Configuration
- //
- void ASync_cs2_config(Uint16 inst, Uint16 async_mem_data_width,
- Uint16 turn_around_time, Uint16 r_hold_time,
- Uint16 r_strobe_time, Uint16 r_setup, Uint16 w_hold,
- Uint16 w_strobe, Uint16 w_setup, Uint16 extend_wait,
- Uint16 strobe_sel)
- {
- if (inst == 0)
- {
- //
- // 1:0 Asynchronous Memory Size.
- // 3:2 Turn Around cycles.
- // 6:4 Read Strobe Hold cycles.
- // 12:7 Read Strobe Duration cycles.
- // 16:13 Read Strobe Setup cycles.
- // 19:17 Write Strobe Hold cycles.
- // 25:20 Write Strobe Duration cycles.
- // 29:26 Write Strobe Setup cycles.
- // 30 Extend Wait mode.
- // 31 Select Strobe mode.
- //
- Emif1Regs.ASYNC_CS2_CR.bit.ASIZE = async_mem_data_width;
- Emif1Regs.ASYNC_CS2_CR.bit.TA= turn_around_time;
- Emif1Regs.ASYNC_CS2_CR.bit.R_HOLD= r_hold_time;
- Emif1Regs.ASYNC_CS2_CR.bit.R_STROBE = r_strobe_time;
- Emif1Regs.ASYNC_CS2_CR.bit.R_SETUP = r_setup;
- Emif1Regs.ASYNC_CS2_CR.bit.W_HOLD = w_hold;
- Emif1Regs.ASYNC_CS2_CR.bit.W_STROBE = w_strobe;
- Emif1Regs.ASYNC_CS2_CR.bit.W_SETUP = w_setup;
- Emif1Regs.ASYNC_CS2_CR.bit.EW = extend_wait;
- Emif1Regs.ASYNC_CS2_CR.bit.SS = strobe_sel;
- }
- else
- {
- //
- // 1:0 Asynchronous Memory Size.
- // 3:2 Turn Around cycles.
- // 6:4 Read Strobe Hold cycles.
- // 12:7 Read Strobe Duration cycles.
- // 16:13 Read Strobe Setup cycles.
- // 19:17 Write Strobe Hold cycles.
- // 25:20 Write Strobe Duration cycles.
- // 29:26 Write Strobe Setup cycles.
- // 30 Extend Wait mode.
- // 31 Select Strobe mode.
- //
- Emif2Regs.ASYNC_CS2_CR.bit.ASIZE = async_mem_data_width;
- Emif2Regs.ASYNC_CS2_CR.bit.TA= turn_around_time;
- Emif2Regs.ASYNC_CS2_CR.bit.R_HOLD= r_hold_time;
- Emif2Regs.ASYNC_CS2_CR.bit.R_STROBE = r_strobe_time;
- Emif2Regs.ASYNC_CS2_CR.bit.R_SETUP = r_setup;
- Emif2Regs.ASYNC_CS2_CR.bit.W_HOLD = w_hold;
- Emif2Regs.ASYNC_CS2_CR.bit.W_STROBE = w_strobe;
- Emif2Regs.ASYNC_CS2_CR.bit.W_SETUP = w_setup;
- Emif2Regs.ASYNC_CS2_CR.bit.EW = extend_wait;
- Emif2Regs.ASYNC_CS2_CR.bit.SS = strobe_sel;
- }
- }
- //
- // ASync_cs3_config - Async CS3 Configuration
- //
- void ASync_cs3_config(Uint16 inst, Uint16 async_mem_data_width,
- Uint16 turn_around_time, Uint16 r_hold_time,
- Uint16 r_strobe_time, Uint16 r_setup, Uint16 w_hold,
- Uint16 w_strobe, Uint16 w_setup, Uint16 extend_wait,
- Uint16 strobe_sel)
- {
- //
- // 1:0 Asynchronous Memory Size.
- // 3:2 Turn Around cycles.
- // 6:4 Read Strobe Hold cycles.
- // 12:7 Read Strobe Duration cycles.
- // 16:13 Read Strobe Setup cycles.
- // 19:17 Write Strobe Hold cycles.
- // 25:20 Write Strobe Duration cycles.
- // 29:26 Write Strobe Setup cycles.
- // 30 Extend Wait mode.
- // 31 Select Strobe mode.
- //
- Emif1Regs.ASYNC_CS3_CR.bit.ASIZE = async_mem_data_width;
- Emif1Regs.ASYNC_CS3_CR.bit.TA= turn_around_time;
- Emif1Regs.ASYNC_CS3_CR.bit.R_HOLD= r_hold_time;
- Emif1Regs.ASYNC_CS3_CR.bit.R_STROBE = r_strobe_time;
- Emif1Regs.ASYNC_CS3_CR.bit.R_SETUP = r_setup;
- Emif1Regs.ASYNC_CS3_CR.bit.W_HOLD = w_hold;
- Emif1Regs.ASYNC_CS3_CR.bit.W_STROBE = w_strobe;
- Emif1Regs.ASYNC_CS3_CR.bit.W_SETUP = w_setup;
- Emif1Regs.ASYNC_CS3_CR.bit.EW = extend_wait;
- Emif1Regs.ASYNC_CS3_CR.bit.SS = strobe_sel;
- }
- //
- // ASync_cs4_config - Async CS4 Configuration
- //
- void ASync_cs4_config(Uint16 inst, Uint16 async_mem_data_width,
- Uint16 turn_around_time, Uint16 r_hold_time,
- Uint16 r_strobe_time, Uint16 r_setup, Uint16 w_hold,
- Uint16 w_strobe, Uint16 w_setup, Uint16 extend_wait,
- Uint16 strobe_sel)
- {
- //
- // 1:0 Asynchronous Memory Size.
- // 3:2 Turn Around cycles.
- // 6:4 Read Strobe Hold cycles.
- // 12:7 Read Strobe Duration cycles.
- // 16:13 Read Strobe Setup cycles.
- // 19:17 Write Strobe Hold cycles.
- // 25:20 Write Strobe Duration cycles.
- // 29:26 Write Strobe Setup cycles.
- // 30 Extend Wait mode.
- // 31 Select Strobe mode.
- //
- Emif1Regs.ASYNC_CS4_CR.bit.ASIZE = async_mem_data_width;
- Emif1Regs.ASYNC_CS4_CR.bit.TA= turn_around_time;
- Emif1Regs.ASYNC_CS4_CR.bit.R_HOLD= r_hold_time;
- Emif1Regs.ASYNC_CS4_CR.bit.R_STROBE = r_strobe_time;
- Emif1Regs.ASYNC_CS4_CR.bit.R_SETUP = r_setup;
- Emif1Regs.ASYNC_CS4_CR.bit.W_HOLD = w_hold;
- Emif1Regs.ASYNC_CS4_CR.bit.W_STROBE = w_strobe;
- Emif1Regs.ASYNC_CS4_CR.bit.W_SETUP = w_setup;
- Emif1Regs.ASYNC_CS4_CR.bit.EW = extend_wait;
- Emif1Regs.ASYNC_CS4_CR.bit.SS = strobe_sel;
- }
- #ifdef CPU1
- //
- // setup_emif1_pinmux_async_16bit - function for EMIF1 GPIO pin setup
- //
- void setup_emif1_pinmux_async_16bit(Uint16 cpu_sel)
- {
- Uint16 i;
- for (i=28; i<=52; i++)
- {
- if ((i != 42) && (i != 43))
- {
- GPIO_SetupPinMux(i,cpu_sel,2);
- }
- }
- for (i=63; i<=87; i++)
- {
- if (i != 84)
- {
- GPIO_SetupPinMux(i,cpu_sel,2);
- }
- }
- GPIO_SetupPinMux(88,cpu_sel,3);
- GPIO_SetupPinMux(89,cpu_sel,3);
- GPIO_SetupPinMux(90,cpu_sel,3);
- GPIO_SetupPinMux(91,cpu_sel,3);
- GPIO_SetupPinMux(92,cpu_sel,3);
- GPIO_SetupPinMux(93,cpu_sel,3);
- GPIO_SetupPinMux(94,cpu_sel,2);
- //
- //setup async mode and enable pull-ups for Data pins
- //
- for (i=69; i<=85; i++)
- {
- if (i != 84)
- {
- GPIO_SetupPinOptions(i,0,0x31); // GPIO_ASYNC||GPIO_PULLUP
- }
- }
- }
- //
- // setup_emif1_pinmux_async_32bit - Setup pinmux for 32bit async
- //
- void setup_emif1_pinmux_async_32bit(Uint16 cpu_sel)
- {
- Uint16 i;
- for (i=28; i<=87; i++)
- {
- if ((i != 42) && (i != 43) && (i != 84))
- {
- GPIO_SetupPinMux(i,cpu_sel,2);
- }
- }
- GPIO_SetupPinMux(88,cpu_sel,3);
- GPIO_SetupPinMux(89,cpu_sel,3);
- GPIO_SetupPinMux(90,cpu_sel,3);
- GPIO_SetupPinMux(91,cpu_sel,3);
- GPIO_SetupPinMux(92,cpu_sel,3);
- GPIO_SetupPinMux(93,cpu_sel,3);
- GPIO_SetupPinMux(94,cpu_sel,2);
- //
- //setup async mode for Data pins
- //
- for (i=53; i<=85; i++)
- {
- if (i != 84)
- {
- GPIO_SetupPinOptions(i,0,0x31);
- }
- }
- }
- //
- // setup_emif2_pinmux_async_16bit - function for EMIF1 GPIO pin setup
- //
- void setup_emif2_pinmux_async_16bit(Uint16 cpu_sel)
- {
- Uint16 i;
- for (i=96; i<=121; i++)
- {
- GPIO_SetupPinMux(i,cpu_sel,3);
- }
- for (i=53; i<=68; i++)
- {
- GPIO_SetupPinMux(i,cpu_sel,3);
- }
- //
- //setup async mode for Data pins
- //
- for (i=53; i<=68; i++)
- {
- GPIO_SetupPinOptions(i,0,0x31);
- }
- }
- //
- // setup_emif1_pinmux_sdram_16bit - Setup pinmux for 16bit SDRAM
- //
- void setup_emif1_pinmux_sdram_16bit(Uint16 cpu_sel)
- {
- int i;
- for (i=29; i<=52; i++)
- {
- if ((i != 42) && (i != 43))
- {
- GPIO_SetupPinMux(i,cpu_sel,2);
- }
- }
- for (i=69; i<=85; i++)
- {
- if (i != 84)
- {
- GPIO_SetupPinMux(i,cpu_sel,2);
- }
- }
- for(i=86; i<=93; i++)
- {
- GPIO_SetupPinMux(i,cpu_sel,3);
- }
- //
- //configure Data pins for Async mode
- //
- for (i = 69; i <= 85; i++)
- {
- if (i != 84)
- {
- GPIO_SetupPinOptions(i,0,0x31);
- }
- }
- GPIO_SetupPinOptions(88,0,0x31);
- GPIO_SetupPinOptions(89,0,0x31);
- GPIO_SetupPinOptions(90,0,0x31);
- GPIO_SetupPinOptions(91,0,0x31);
- }
- //
- // setup_emif2_pinmux_sdram_16bit - Setup pinmux for 16bit SDRAM
- //
- void setup_emif2_pinmux_sdram_16bit(Uint16 cpu_sel)
- {
- int i;
- for (i=53; i<=68; i++)
- {
- GPIO_SetupPinMux(i,cpu_sel,3);
- }
- for (i=96; i<=121; i++)
- {
- GPIO_SetupPinMux(i,cpu_sel,3);
- }
- //
- //configure Data pins for Async mode
- //
- for (i = 53; i <= 68; i++)
- {
- GPIO_SetupPinOptions(i,0,0x31);
- }
- }
- //
- // setup_emif1_pinmux_sdram_32bit - Setup pinmux for 32bit SDRAM
- //
- void setup_emif1_pinmux_sdram_32bit(Uint16 cpu_sel)
- {
- int i;
- for (i=28; i<=85; i++)
- {
- if ((i != 42) && (i != 43) && (i != 84))
- {
- GPIO_SetupPinMux(i,cpu_sel,2);
- }
- }
- for(i=86; i<=93; i++)
- {
- GPIO_SetupPinMux(i,cpu_sel,3);
- }
- GPIO_SetupPinMux(94,cpu_sel,2);
- //
- //configure Data pins for Async mode
- //
- for (i = 53; i <= 85; i++)
- {
- if (i != 84)
- {
- GPIO_SetupPinOptions(i,0,0x31);
- }
- }
- GPIO_SetupPinOptions(88,0,0x31);
- GPIO_SetupPinOptions(89,0,0x31);
- GPIO_SetupPinOptions(90,0,0x31);
- GPIO_SetupPinOptions(91,0,0x31);
- }
- #endif // CPU1
- //
- // End of file
- //
|