Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
@@ -0,0 +1,25 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="cm_common_config_c28x"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define RAM --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../c28x/cm_common_config_c28x/cm_common_config_c28x.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,25 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="uart_config_c28x"
|
||||
device="TMS320F28388D"
|
||||
cgtVersion="22.6.1.LTS"
|
||||
products="C2000WARE"
|
||||
outputFormat="ELF"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CPU1_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -v28 -ml -mt --cla_support=cla2 --define RAM --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=UART --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200" />
|
||||
<configuration name="CPU1_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -v28 -ml -mt --cla_support=cla2 --float_support=fpu64 --tmu_support=tmu0 --define=DEBUG --define=CPU1 --define=UART --diag_warning=225 --diag_suppress=10063" linkerBuildOptions="--entry_point code_start --stack_size=0x3F8 --heap_size=0x200" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/device.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/device.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cpu1.cmd" targetDirectory="" applicableConfigurations="CPU1_FLASH" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/f2838x_codestartbranch.asm" targetDirectory="device" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib/ccs/Debug/driverlib.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="copy" path="../../../c28x/cm_common_config_c28x/cm_common_config_c28x.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,25 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="uart_ex1_echoback"
|
||||
device="Cortex M.TMS320F28388D"
|
||||
cgtVersion="20.2.7.LTS"
|
||||
products="C2000WARE"
|
||||
endianness="little"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CM_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=DEBUG --float_support=none -mv7M4 -me --diag_warning=225 " linkerBuildOptions="--stack_size=512 --heap_size=1024 --library=libc.a --define RAM" />
|
||||
<configuration name="CM_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=DEBUG --float_support=none --define=_FLASH -mv7M4 -me --diag_warning=225 " linkerBuildOptions="--stack_size=512 --heap_size=1024 --library=libc.a " />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib_cm/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib_cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/cm.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cm.cmd" targetDirectory="" applicableConfigurations="CM_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cm.cmd" targetDirectory="" applicableConfigurations="CM_FLASH" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib_cm/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib_cm/ccs/Debug/driverlib_cm.lib" targetDirectory="" />
|
||||
<file action="copy" path="../uart_ex1_echoback.c" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/startup_cm.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,25 @@
|
||||
<projectSpec>
|
||||
<project
|
||||
name="uart_ex2_loopback_udma"
|
||||
device="Cortex M.TMS320F28388D"
|
||||
cgtVersion="20.2.7.LTS"
|
||||
products="C2000WARE"
|
||||
endianness="little"
|
||||
launchWizard="False"
|
||||
linkerCommandFile=""
|
||||
>
|
||||
<configuration name="CM_RAM" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} -mv7M4 --define=DEBUG --float_support=none --diag_warning=225 " linkerBuildOptions="--stack_size=512 --heap_size=1024 --library=libc.a" />
|
||||
<configuration name="CM_FLASH" compilerBuildOptions="--opt_level=off -I${PROJECT_ROOT}/device -I${C2000WARE_DLIB_ROOT} --define=_FLASH -mv7M4 --define=DEBUG --float_support=none --diag_warning=225 " linkerBuildOptions="--stack_size=512 --heap_size=1024 --library=libc.a" />
|
||||
<pathVariable name="C2000WARE_DLIB_ROOT" path="../../../../../../driverlib/f2838x/driverlib_cm/" scope="project" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/driverlib_cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/include/cm.h" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/cm.c" targetDirectory="device" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/targetConfigs/TMS320F28388D.ccxml" targetDirectory="targetConfigs" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_RAM_lnk_cm.cmd" targetDirectory="" applicableConfigurations="CM_RAM" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/cmd/2838x_FLASH_lnk_cm.cmd" targetDirectory="" applicableConfigurations="CM_FLASH" />
|
||||
<file action="copy" path="../../../../../../driverlib/f2838x/driverlib_cm/" targetDirectory="device" excludeFromBuild="True" />
|
||||
<file action="link" path="../../../../../../driverlib/f2838x/driverlib_cm/ccs/Debug/driverlib_cm.lib" targetDirectory="" />
|
||||
<file action="copy" path="../../../../../../device_support/f2838x/common/source/startup_cm.c" targetDirectory="" />
|
||||
<file action="copy" path="../uart_ex2_loopback_udma.c" targetDirectory="" />
|
||||
</project>
|
||||
</projectSpec>
|
||||
@@ -0,0 +1,181 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: UART_ex1_echoback.c
|
||||
//
|
||||
// TITLE: UART echoback example.
|
||||
//
|
||||
//! \addtogroup driver_example_cm_list
|
||||
//! <h1>UART Echoback</h1>
|
||||
//!
|
||||
//! This test receives and echo-backs data through the UART0 port.
|
||||
//!
|
||||
//! A terminal such as 'putty' can be used to view the data from
|
||||
//! the CM-UART and to send information to the CM-UART. Characters
|
||||
//! received by the CM-UART port are sent back to the host.
|
||||
//!
|
||||
//! \b Running \b the \b Application
|
||||
//! Open a COM port with the following settings using a terminal:
|
||||
//! - Find correct COM port
|
||||
//! - Bits per second = 115200
|
||||
//! - Data Bits = 8
|
||||
//! - Parity = None
|
||||
//! - Stop Bits = 1
|
||||
//! - Hardware Control = None
|
||||
//!
|
||||
//! The program will print out a greeting and then ask you to
|
||||
//! enter a character which it will echo back to the terminal.
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - None
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! Connect the UART0 port to a PC via a transceiver and cable.
|
||||
//! - GPIO85 is UART0RX/CMUARTRXA(Connect to Pin3, PC-TX, of serial DB9 cable)
|
||||
//! - GPIO84 is UART0TX/CMUARTTXA(Connect to Pin2, PC-RX, of serial DB9 cable)
|
||||
//!
|
||||
//! \note The pin muxing for the UART0 port needs to be done by the master
|
||||
//! CPU1. The common configuration example provided in the C28x folder can be
|
||||
//! used for making GPIO85 as the UART Rx pin and GPIO84 as the UART Tx pin.
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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 <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "cm.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
//
|
||||
#define NUM_UART_DATA 4
|
||||
|
||||
//
|
||||
// Function Prototypes
|
||||
//
|
||||
__interrupt void UART_RX_IntHandler(void);
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
|
||||
//
|
||||
// disable WD, enable peripheral clocks.
|
||||
//
|
||||
CM_init();
|
||||
|
||||
//
|
||||
// Configure UART0 for echoback.Set up to transfer data at 115200 baud.
|
||||
//
|
||||
UART_setConfig(UART0_BASE,UART_CLK_FREQ , 115200,(UART_CONFIG_WLEN_8 |
|
||||
UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
|
||||
|
||||
//
|
||||
// Put a character to show start of example. This will display on the
|
||||
// terminal.
|
||||
//
|
||||
UART_writeChar(UART0_BASE, '!');
|
||||
|
||||
//
|
||||
// Enable the UART0 interrupt on the processor (NVIC).
|
||||
//
|
||||
UART_registerInterrupt(INT_UART0,UART_RX_IntHandler);
|
||||
|
||||
//
|
||||
// FIFO enable
|
||||
//
|
||||
UART_enableFIFO(UART0_BASE);
|
||||
|
||||
//
|
||||
// FIFO interrupt levels are set to generate an interrupt
|
||||
// when the TX FIFO is less than or equal to 7/8 empty and the
|
||||
// RX FIFO is greater than or equal to 1/8 full.
|
||||
//
|
||||
UART_setFIFOLevel(UART0_BASE, UART_FIFO_TX1_8, UART_FIFO_RX1_8);
|
||||
|
||||
//
|
||||
// FIFO receive interrupt configuration
|
||||
//
|
||||
UART_clearInterruptStatus(UART0_BASE,UART_INT_RX | UART_INT_RT);
|
||||
UART_enableInterrupt(UART0_BASE,UART_INT_RX);
|
||||
|
||||
//
|
||||
// Loop forever echoing data through the UART.
|
||||
//
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
__interrupt void UART_RX_IntHandler(void)
|
||||
{
|
||||
uint32_t ui32Status;
|
||||
|
||||
//
|
||||
// Get the interrupt status.
|
||||
//
|
||||
ui32Status = UART_getInterruptStatus(UART0_BASE, UART_RAW_INT);
|
||||
|
||||
//
|
||||
// Clear the asserted interrupts.
|
||||
//
|
||||
UART_clearInterruptStatus(UART0_BASE, ui32Status);
|
||||
|
||||
//
|
||||
// Loop while there are characters in the receive FIFO.
|
||||
//
|
||||
while(UART_isDataAvailable(UART0_BASE))
|
||||
{
|
||||
//
|
||||
// Read the next character from the UART and write it back to the UART.
|
||||
//
|
||||
UART_writeCharNonBlocking(UART0_BASE,
|
||||
UART_readCharNonBlocking(UART0_BASE));
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// End of File
|
||||
//
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
//#############################################################################
|
||||
//
|
||||
// FILE: uart_ex2_loopback_udma.c
|
||||
//
|
||||
// TITLE: UART loopback example
|
||||
//
|
||||
//! \addtogroup driver_example_cm_list
|
||||
//! <h1>UART Loopback example with UDMA</h1>
|
||||
//!
|
||||
//! This example showcases how to use UDMA with UART to transfer and receive data
|
||||
//!
|
||||
//! This configures the UART in loopback mode and sends and receives data for
|
||||
//! infinite time.
|
||||
//! cm_common_config_c28x example needs to be run on C28x1 before running this
|
||||
//! example on the CM core
|
||||
//!
|
||||
//! \b Configuration:
|
||||
//! - Find correct COM port
|
||||
//! - Bits per second = 115200
|
||||
//! - Data Bits = 8
|
||||
//! - Parity = None
|
||||
//! - Stop Bits = 1
|
||||
//! - Hardware Control = None
|
||||
//!
|
||||
//! \b External \b Connections \n
|
||||
//! - None
|
||||
//!
|
||||
//! \b Watch \b Variables \n
|
||||
//! - \b TxData - Data transmitted
|
||||
//! - \b RxData - Data received
|
||||
//! - \b errCount - Error count
|
||||
//!
|
||||
//
|
||||
//#############################################################################
|
||||
//
|
||||
//
|
||||
//
|
||||
// C2000Ware v5.04.00.00
|
||||
//
|
||||
// Copyright (C) 2024 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.
|
||||
// $
|
||||
//#############################################################################
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cm.h"
|
||||
#include "driverlib_cm.h"
|
||||
|
||||
#pragma DATA_ALIGN(ucControlTable, 1024)
|
||||
UDMA_ControlTable ucControlTable[64];
|
||||
|
||||
//
|
||||
// Initialize the data arrays
|
||||
//
|
||||
uint8_t TxData[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC, 0xD, 0xE, 0xF};
|
||||
uint8_t RxData[] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
|
||||
|
||||
void ConfigureUART(void)
|
||||
{
|
||||
|
||||
//
|
||||
// Configure UART with baud rate = 115200, dataWidth = 8
|
||||
//
|
||||
UART_setConfig(UART0_BASE,UART_CLK_FREQ , 115200,
|
||||
(UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
|
||||
UART_CONFIG_PAR_NONE));
|
||||
|
||||
//
|
||||
// Enable the UART0 module.
|
||||
//
|
||||
UART_enableModule(UART0_BASE);
|
||||
|
||||
//
|
||||
// Enable loopback mode
|
||||
//
|
||||
UART_enableLoopback(UART0_BASE);
|
||||
}
|
||||
|
||||
void ConfigureDMA(uint8_t* TxDma, uint8_t* RxDma, uint8_t size)
|
||||
{
|
||||
//
|
||||
// Enable DMA for Tx snd Rx events
|
||||
//
|
||||
UART_enableDMA(UART0_BASE,UART_DMA_TX |UART_DMA_RX);
|
||||
|
||||
//
|
||||
// Enable UDMA
|
||||
//
|
||||
UDMA_enable(UDMA_BASE);
|
||||
|
||||
//
|
||||
// Point at the control table to use for channel control structures.
|
||||
//
|
||||
UDMA_setControlBase(UDMA_BASE, ucControlTable);
|
||||
|
||||
//
|
||||
// Put the attributes in a known state for the uDMA software channel.
|
||||
// These should already be disabled by default.
|
||||
//
|
||||
UDMA_disableChannelAttribute(UDMA_BASE, UDMA_CHANNEL_UART0_TX, UDMA_CH_ATTR_ALL);
|
||||
UDMA_disableChannelAttribute(UDMA_BASE, UDMA_CHANNEL_UART0_RX, UDMA_CH_ATTR_ALL);
|
||||
|
||||
//
|
||||
// Configure the control parameters for the UART TX channels
|
||||
// Tx channel will be used to transfer data from the buffer to the UART Data
|
||||
// register.
|
||||
// Data size = 8
|
||||
// Source address increment = 8 (data to be read from 8-bit buffer)
|
||||
// Destination address increment = 0 (data to be copied to a single address location)
|
||||
//
|
||||
// The arbitration size will be set to 1, which causes the uDMA controller
|
||||
// to re-arbitrate after 1 item is transferred.
|
||||
//
|
||||
UDMA_setChannelControlParams(UDMA_BASE, (UDMA_CHANNEL_UART0_TX | UDMA_PRI_SELECT),
|
||||
(UDMA_SIZE_8 | UDMA_SRC_INC_8 | UDMA_DST_INC_NONE
|
||||
| UDMA_ARB_1));
|
||||
|
||||
UDMA_setChannelTransferParams(UDMA_BASE, (UDMA_CHANNEL_UART0_TX | UDMA_PRI_SELECT),
|
||||
TxDma, (void *)(UART0_BASE + UART_O_DR), UDMA_MODE_BASIC,
|
||||
size);
|
||||
|
||||
//
|
||||
// Configure the control parameters for the UART RX channel.
|
||||
// Rx channel will be used to transfer data from the UART Data register to
|
||||
// the buffer.
|
||||
//
|
||||
// Data size = 8
|
||||
// Source address increment = 0 (data to be read from a single address location)
|
||||
// Destination address increment = 8 (data to be copied to a 8-bit buffer)
|
||||
//
|
||||
// The arbitration size will be set to 1, which causes the uDMA controller
|
||||
// to re arbitrate after 1 item is transferred.
|
||||
//
|
||||
UDMA_setChannelControlParams(UDMA_BASE, (UDMA_CHANNEL_UART0_RX | UDMA_PRI_SELECT),
|
||||
(UDMA_SIZE_8 | UDMA_SRC_INC_NONE | UDMA_DST_INC_8
|
||||
| UDMA_ARB_1));
|
||||
|
||||
UDMA_setChannelTransferParams(UDMA_BASE, (UDMA_CHANNEL_UART0_RX | UDMA_PRI_SELECT),
|
||||
(void *)(UART0_BASE + UART_O_DR), RxDma, UDMA_MODE_BASIC,
|
||||
size);
|
||||
}
|
||||
|
||||
//
|
||||
// Main
|
||||
//
|
||||
void main(void)
|
||||
{
|
||||
uint8_t i;
|
||||
uint8_t errCount = 0;
|
||||
|
||||
//
|
||||
// Disable WD, enable peripheral clocks.
|
||||
//
|
||||
CM_init();
|
||||
|
||||
//
|
||||
// Configure the UART
|
||||
//
|
||||
ConfigureUART();
|
||||
|
||||
//
|
||||
// Configure the UDMA to read/write to the TX/RX buffers
|
||||
//
|
||||
ConfigureDMA(TxData, RxData, 16);
|
||||
|
||||
//
|
||||
// Enable the UDMA channels
|
||||
//
|
||||
UDMA_enableChannel(UDMA_BASE, UDMA_CHANNEL_UART0_RX);
|
||||
UDMA_enableChannel(UDMA_BASE, UDMA_CHANNEL_UART0_TX);
|
||||
|
||||
//
|
||||
// Wait until the complete transfer is done
|
||||
//
|
||||
while(UDMA_isChannelEnabled(UDMA_BASE, UDMA_CHANNEL_UART0_TX));
|
||||
while(UDMA_isChannelEnabled(UDMA_BASE, UDMA_CHANNEL_UART0_RX));
|
||||
|
||||
//
|
||||
// Check the received data
|
||||
//
|
||||
for(i = 0; i < 16; i++)
|
||||
{
|
||||
if(TxData[i] != RxData[i])
|
||||
{
|
||||
errCount++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Loop forever. Optional
|
||||
//
|
||||
while(1);
|
||||
}
|
||||
Reference in new issue
Block a user