Update repo

This commit is contained in:
hangpersonal committed 2026-08-30 23:04:35 -07:00
1 parent 749dab5721
commit ce65a0f59a
14950 files changed
+4408250 -1

No files matched your search

@@ -0,0 +1,576 @@
//###########################################################################
//
// FILE: aes.c
//
// TITLE: Driver for the AES module.
//
//###########################################################################
//
// 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 "aes.h"
//*****************************************************************************
//
// AES_configureModule
//
//*****************************************************************************
void
AES_configureModule(uint32_t base, const AES_ConfigParams *config)
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Write the ctrl register with new value and backup the save context field
//
HWREG_BP(base + AES_O_CTRL) = ((HWREG_BP(base + AES_O_CTRL) &
~AES_CONFIG_M) |
((uint32_t)config->direction |
(uint32_t)config->keySize |
(uint32_t)config-> opMode |
(uint32_t)config->ctrWidth |
(uint32_t)config->ccmLenWidth |
(uint32_t)config->ccmAuthLenWidth));
}
//*****************************************************************************
//
// AES_setKey1
//
//*****************************************************************************
void
AES_setKey1(uint32_t base, const uint32_t key[], AES_KeySize keySize)
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// With all key sizes, the first 4 words are written.
//
HWREG_BP(base + AES_O_KEY1_0) = key[0U];
HWREG_BP(base + AES_O_KEY1_1) = key[1U];
HWREG_BP(base + AES_O_KEY1_2) = key[2U];
HWREG_BP(base + AES_O_KEY1_3) = key[3U];
//
// The key is 192 or 256 bits. Write the next 2 words.
//
if(keySize != AES_KEY_SIZE_128BIT)
{
HWREG_BP(base + AES_O_KEY1_4) = key[4U];
HWREG_BP(base + AES_O_KEY1_5) = key[5U];
}
//
// The key is 256 bits. Write the last 2 words.
//
if(keySize == AES_KEY_SIZE_256BIT)
{
HWREG_BP(base + AES_O_KEY1_6) = key[6U];
HWREG_BP(base + AES_O_KEY1_7) = key[7U];
}
}
//*****************************************************************************
//
// AES_setKey2
//
//*****************************************************************************
void
AES_setKey2(uint32_t base, const uint32_t key[], AES_KeySize keySize)
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// With all key sizes, the first 4 words are written.
//
HWREG_BP(base + AES_O_KEY2_0) = key[0U];
HWREG_BP(base + AES_O_KEY2_1) = key[1U];
HWREG_BP(base + AES_O_KEY2_2) = key[2U];
HWREG_BP(base + AES_O_KEY2_3) = key[3U];
//
// The key is 192 or 256 bits. Write the next 2 words.
//
if(keySize != AES_KEY_SIZE_128BIT)
{
HWREG_BP(base + AES_O_KEY2_4) = key[4U];
HWREG_BP(base + AES_O_KEY2_5) = key[5U];
}
//
// The key is 256 bits. Write the last 2 words.
//
if(keySize == AES_KEY_SIZE_256BIT)
{
HWREG_BP(base + AES_O_KEY2_6) = key[6U];
HWREG_BP(base + AES_O_KEY2_7) = key[7U];
}
}
//*****************************************************************************
//
// AES_setKey3
//
//*****************************************************************************
void
AES_setKey3(uint32_t base, const uint32_t key[])
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// With all key sizes, the first 4 words are written.
//
HWREG_BP(base + AES_O_KEY2_4) = key[0U];
HWREG_BP(base + AES_O_KEY2_5) = key[1U];
HWREG_BP(base + AES_O_KEY2_6) = key[2U];
HWREG_BP(base + AES_O_KEY2_7) = key[3U];
}
//*****************************************************************************
//
// AES_setInitializationVector
//
//*****************************************************************************
void
AES_setInitializationVector(uint32_t base, const uint32_t iniVector[])
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Set Initialization vector.
//
HWREG_BP(base + AES_O_IV_IN_OUT_0) = iniVector[0U];
HWREG_BP(base + AES_O_IV_IN_OUT_1) = iniVector[1U];
HWREG_BP(base + AES_O_IV_IN_OUT_2) = iniVector[2U];
HWREG_BP(base + AES_O_IV_IN_OUT_3) = iniVector[3U];
}
//*****************************************************************************
//
// AES_readInitializationVector
//
//*****************************************************************************
void
AES_readInitializationVector(uint32_t base, uint32_t iniVector[])
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Read the initialization vector
//
iniVector[0U] = HWREG_BP(base + AES_O_IV_IN_OUT_0);
iniVector[1U] = HWREG_BP(base + AES_O_IV_IN_OUT_1);
iniVector[2U] = HWREG_BP(base + AES_O_IV_IN_OUT_2);
iniVector[3U] = HWREG_BP(base + AES_O_IV_IN_OUT_3);
}
//*****************************************************************************
//
// AES_readTag
//
//*****************************************************************************
void
AES_readTag(uint32_t base, uint32_t tagData[])
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Wait for the output context to be ready.
//
while((AES_CTRL_SVCTXTRDY & (HWREG_BP(base + AES_O_CTRL))) !=
AES_CTRL_SVCTXTRDY)
{
}
//
// Read the tag data.
//
tagData[0U] = HWREG_BP(base + AES_O_TAG_OUT_0);
tagData[1U] = HWREG_BP(base + AES_O_TAG_OUT_1);
tagData[2U] = HWREG_BP(base + AES_O_TAG_OUT_2);
tagData[3U] = HWREG_BP(base + AES_O_TAG_OUT_3);
}
//*****************************************************************************
//
// AES_readDataNonBlocking
//
//*****************************************************************************
bool
AES_readDataNonBlocking(uint32_t base, uint32_t destArray[])
{
bool temp;
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Check if the output is ready before reading the data. If it is not
// ready, return false.
//
if((AES_CTRL_OUTPUT_READY & (HWREG_BP(base + AES_O_CTRL))) !=
AES_CTRL_OUTPUT_READY)
{
temp = false;
}
else
{
//
// Read a block of data from the data registers
//
destArray[0U] = HWREG_BP(base + AES_O_DATA_IN_OUT_3);
destArray[1U] = HWREG_BP(base + AES_O_DATA_IN_OUT_2);
destArray[2U] = HWREG_BP(base + AES_O_DATA_IN_OUT_1);
destArray[3U] = HWREG_BP(base + AES_O_DATA_IN_OUT_0);
//
// Read successful, return true.
//
temp = true;
}
return(temp);
}
//*****************************************************************************
//
// AES_readDataBlocking
//
//*****************************************************************************
void
AES_readDataBlocking(uint32_t base, uint32_t destArray[])
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Wait for the output to be ready before reading the data.
//
while((AES_CTRL_OUTPUT_READY & (HWREG_BP(base + AES_O_CTRL))) !=
AES_CTRL_OUTPUT_READY)
{
}
//
// Read a block of data from the data registers
//
destArray[0U] = HWREG_BP(base + AES_O_DATA_IN_OUT_3);
destArray[1U] = HWREG_BP(base + AES_O_DATA_IN_OUT_2);
destArray[2U] = HWREG_BP(base + AES_O_DATA_IN_OUT_1);
destArray[3U] = HWREG_BP(base + AES_O_DATA_IN_OUT_0);
}
//*****************************************************************************
//
// AES_writeDataNonBlocking
//
//*****************************************************************************
bool
AES_writeDataNonBlocking(uint32_t base, const uint32_t srcArray[])
{
bool temp;
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Check if the input is ready. If not, then return false.
//
if((AES_CTRL_INPUT_READY & (HWREG_BP(base + AES_O_CTRL))) !=
AES_CTRL_INPUT_READY)
{
temp = false;
}
else
{
//
// Write a block of data into the data registers.
//
HWREG_BP(base + AES_O_DATA_IN_OUT_3) = srcArray[0U];
HWREG_BP(base + AES_O_DATA_IN_OUT_2) = srcArray[1U];
HWREG_BP(base + AES_O_DATA_IN_OUT_1) = srcArray[2U];
HWREG_BP(base + AES_O_DATA_IN_OUT_0) = srcArray[3U];
//
// Write successful, return true.
//
temp = true;
}
return(temp);
}
//*****************************************************************************
//
// AES_writeDataBlocking
//
//*****************************************************************************
void
AES_writeDataBlocking(uint32_t base, const uint32_t srcArray[])
{
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Wait for input ready.
//
while((AES_CTRL_INPUT_READY & (HWREG_BP(base + AES_O_CTRL))) !=
AES_CTRL_INPUT_READY)
{
}
//
// Write a block of data into the data registers.
//
HWREG_BP(base + AES_O_DATA_IN_OUT_3) = srcArray[0U];
HWREG_BP(base + AES_O_DATA_IN_OUT_2) = srcArray[1U];
HWREG_BP(base + AES_O_DATA_IN_OUT_1) = srcArray[2U];
HWREG_BP(base + AES_O_DATA_IN_OUT_0) = srcArray[3U];
}
//*****************************************************************************
//
// AES_processData
//
//*****************************************************************************
bool
AES_processData(uint32_t base, const uint32_t srcArray[], uint32_t destArray[],
uint64_t dataLength)
{
uint64_t count;
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Write the length register first, which triggers the engine to start
// using this context.
//
AES_setDataLength(base, dataLength);
//
// Now loop until the blocks are written.
//
for(count = 0U; count < ((dataLength + 15U) / 16U); count++)
{
//
// Write the data registers.
//
AES_writeDataBlocking(base, srcArray + (count * 4U));
//
// Read the data registers.
//
AES_readDataBlocking(base, destArray + (count * 4U));
}
//
// Return true to indicate successful completion of the function.
//
return((bool)true);
}
//*****************************************************************************
//
// AES_authenticateData
//
//*****************************************************************************
bool
AES_authenticateData(uint32_t base, const uint32_t srcArray[],
uint64_t dataLength, uint32_t tagArray[])
{
uint32_t count;
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Write the length register first, which triggers the engine to start
// using this context.
//
AES_setDataLength(base, dataLength);
//
// Now loop until the blocks are written.
//
for(count = 0U; count < ((dataLength + 15U) / 16U); count++)
{
//
// Write the data registers.
//
AES_writeDataBlocking(base, srcArray + (count * 4U));
}
//
// Read the hash tag value.
//
AES_readTag(base, tagArray);
//
// Return true to indicate successful completion of the function.
//
return((bool)true);
}
//*****************************************************************************
//
// AES_processDatainAuthMode
//
//*****************************************************************************
bool
AES_processDatainAuthMode(uint32_t base, const uint32_t srcArray[],
uint32_t destArray[], uint64_t dataLength,
const uint32_t authDataArray[],
uint32_t authDataLength, uint32_t tagArray[])
{
uint32_t count;
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
//
// Set the data length.
//
AES_setDataLength(base, dataLength);
//
// Set the additional authentication data length.
//
AES_setAuthDataLength(base, authDataLength);
//
// Now loop until the authentication data blocks are written.
//
for(count = 0U; count < ((authDataLength + 15U) / 16U); count++)
{
//
// Write the data registers.
//
AES_writeDataBlocking(base, authDataArray + (count * 4U));
}
//
// Now loop until the data blocks are written.
//
for(count = 0U; count < ((dataLength + 15U) / 16U); count++)
{
//
// Write the data registers.
//
AES_writeDataBlocking(base, srcArray + (count * 4U));
//
//
// Read the data registers.
//
AES_readDataBlocking(base, destArray + (count * 4U));
}
//
// Read the hash tag value.
//
AES_readTag(base, tagArray);
//
// Return true to indicate successful completion of the function.
//
return((bool)true);
}
//*****************************************************************************
//
// AES_getInterruptStatus
//
//*****************************************************************************
uint32_t
AES_getInterruptStatus(uint32_t base, uint32_t wrapperBase, bool intMask)
{
uint32_t intStatus, intEnable;
//
// Check the arguments.
//
ASSERT(AES_isBaseValid(base));
ASSERT(AES_isWrapperBaseValid(wrapperBase));
//
// Read the IRQ status register and return the value.
//
intStatus = HWREG_BP(base + AES_O_IRQSTATUS) |
(HWREG_BP(wrapperBase + AES_SS_O_AESDMASTATUS) << 16U);
if(intMask)
{
intEnable = HWREG_BP(base + AES_O_IRQENABLE) |
(HWREG_BP(wrapperBase + AES_SS_O_AESDMAINTEN) << 16U);
intStatus &= intEnable;
}
return(intStatus);
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,37 @@
<projectSpec>
<project
name="f2838x_driverlib_cm"
device="Generic CortexM4 Device"
cgtVersion="20.2.6.LTS"
products="C2000WARE"
launchWizard="False"
outputType="staticLibrary"
location="."
>
<configuration name="Debug" compilerBuildOptions=" -I../ -mv7M4 --float_support=none -me --opt_level=off --gen_func_subsections=on --gen_data_subsections=on " archiverBuildOptions="driverlib_cm.lib" />
<configuration name="Release" compilerBuildOptions=" -I../ -mv7M4 -me -O2 --float_support=none --advice:power=all --diag_warning=225 --diag_wrap=off --display_error_number --gen_func_subsections=on --gen_data_subsections=on --ual" archiverBuildOptions="driverlib_cm.lib" />
<file action="link" path="../aes.c" targetDirectory="." />
<file action="link" path="../can.c" targetDirectory="." />
<file action="link" path="../cmmpu.c" targetDirectory="." />
<file action="link" path="../cputimer.c" targetDirectory="." />
<file action="link" path="../dcsm.c" targetDirectory="." />
<file action="link" path="../escss.c" targetDirectory="." />
<file action="link" path="../ethernet.c" targetDirectory="." />
<file action="link" path="../flash.c" targetDirectory="." />
<file action="link" path="../gcrc.c" targetDirectory="." />
<file action="link" path="../gpio.c" targetDirectory="." />
<file action="link" path="../i2c.c" targetDirectory="." />
<file action="link" path="../interrupt.c" targetDirectory="." />
<file action="link" path="../ipc.c" targetDirectory="." />
<file action="link" path="../mcan.c" targetDirectory="." />
<file action="link" path="../memcfg.c" targetDirectory="." />
<file action="link" path="../mpu.c" targetDirectory="." />
<file action="link" path="../platform_port.c" targetDirectory="." />
<file action="link" path="../ssi.c" targetDirectory="." />
<file action="link" path="../sysctl.c" targetDirectory="." />
<file action="link" path="../systick.c" targetDirectory="." />
<file action="link" path="../uart.c" targetDirectory="." />
<file action="link" path="../udma.c" targetDirectory="." />
<file action="link" path="../usb.c" targetDirectory="." />
</project>
</projectSpec>
@@ -0,0 +1,44 @@
//###########################################################################
//
// FILE: cmmpu.c
//
// TITLE: Driver for the uDMA & EMAC memory protection unit (MPU).
//
//###########################################################################
//
// 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 "cmmpu.h"
@@ -0,0 +1,748 @@
//###########################################################################
//
// FILE: cmmpu.h
//
// TITLE: Driver for the uDMA & EMAC memory protection unit (MPU).
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef CMMPU_H
#define CMMPU_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup cmmpu_api CMMPU
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "debug.h"
#include "interrupt.h"
#include "inc/hw_cmmpu.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
//*****************************************************************************
//
// Defines for the API.
//
//*****************************************************************************
//*****************************************************************************
//
// Key for accessing Access Violation related registers.
//
//*****************************************************************************
#define CMMPU_ACC_VIO_KEY 0xA5A50000U //!< Key for ACC VIO Registers
//*****************************************************************************
//
// Flags for setting/clearing/returning the access violation interrupt flag
// status, to be passed to CMMPU_setAccessViolationFlags() &
// CMMPU_setAccessViolationFlags() as flags parameter & returned by
// CMMPU_getAccessViolationFlags().
//
//*****************************************************************************
#define CMMPU_ACC_VIO_FLAGS_READ CMMPU_ACC_VIO_FLAGS_RD //!< Read Violation
#define CMMPU_ACC_VIO_FLAGS_WRITE CMMPU_ACC_VIO_FLAGS_WR //!< Write Violation
//*****************************************************************************
//
// Values that can be passed to CMMPU_setRegionAttributes() and
// CMMPU_getRegionAttributes() as regionNum parameter.
//
//*****************************************************************************
#define CMMPU_RGN_0 0x0U //!< Select uDMA/EMAC MPU Region 0
#define CMMPU_RGN_1 0x1U //!< Select uDMA/EMAC MPU Region 1
#define CMMPU_RGN_2 0x2U //!< Select uDMA/EMAC MPU Region 2
#define CMMPU_RGN_3 0x3U //!< Select uDMA/EMAC MPU Region 3
#define CMMPU_RGN_4 0x4U //!< Select uDMA/EMAC MPU Region 4
#define CMMPU_RGN_5 0x5U //!< Select uDMA/EMAC MPU Region 5
#define CMMPU_RGN_6 0x6U //!< Select uDMA/EMAC MPU Region 6
#define CMMPU_RGN_7 0x7U //!< Select uDMA/EMAC MPU Region 7
//*****************************************************************************
//
// Flags to enable or disable a region, to be passed to
// CMMPU_setRegionAttributes().
//
//*****************************************************************************
#define CMMPU_RGN_ENABLE 0x1U //!< Enable MPU Region
#define CMMPU_RGN_DISABLE 0x0U //!< Disable MPU Region
//*****************************************************************************
//
// Flags for the access permissions to be passed to CMMPU_setRegionAttributes().
//
//*****************************************************************************
#define CMMPU_RGN_PERM_READ_ONLY 0x00U //!< Read Only Access
#define CMMPU_RGN_PERM_NO_ACCESS 0x20U //!< No Access(R/W)
#define CMMPU_RGN_PERM_FULL_ACCESS 0x10U //!< Full Access(R/W)
//*****************************************************************************
//
// Flags for the region size to be passed to CMMPU_setRegionAttributes().
//
//*****************************************************************************
#define CMMPU_RGN_SIZE_1K (0x0U << 8U) //!< Region Size is 1K-bytes
#define CMMPU_RGN_SIZE_2K (0x1U << 8U) //!< Region Size is 2K-bytes
#define CMMPU_RGN_SIZE_4K (0x2U << 8U) //!< Region Size is 4K-bytes
#define CMMPU_RGN_SIZE_8K (0x3U << 8U) //!< Region Size is 8K-bytes
#define CMMPU_RGN_SIZE_16K (0x4U << 8U) //!< Region Size is 16K-bytes
#define CMMPU_RGN_SIZE_32K (0x5U << 8U) //!< Region Size is 32K-bytes
#define CMMPU_RGN_SIZE_64K (0x6U << 8U) //!< Region Size is 64K-bytes
#define CMMPU_RGN_SIZE_128K (0x7U << 8U) //!< Region Size is 128K-bytes
#define CMMPU_RGN_SIZE_256K (0x8U << 8U) //!< Region Size is 256K-bytes
#define CMMPU_RGN_SIZE_512K (0x9U << 8U) //!< Region Size is 512K-bytes
#define CMMPU_RGN_SIZE_1M (0xAU << 8U) //!< Region Size is 1M-bytes
#define CMMPU_RGN_SIZE_2M (0xBU << 8U) //!< Region Size is 2M-bytes
#define CMMPU_RGN_SIZE_4M (0xCU << 8U) //!< Region Size is 4M-bytes
#define CMMPU_RGN_SIZE_8M (0xDU << 8U) //!< Region Size is 8M-bytes
#define CMMPU_RGN_SIZE_16M (0xEU << 8U) //!< Region Size is 16M-bytes
#define CMMPU_RGN_SIZE_32M (0xFU << 8U) //!< Region Size is 32M-bytes
#define CMMPU_RGN_SIZE_64M (0x10U << 8U) //!< Region Size is 64M-bytes
#define CMMPU_RGN_SIZE_128M (0x11U << 8U) //!< Region Size is 128M-bytes
#define CMMPU_RGN_SIZE_256M (0x12U << 8U) //!< Region Size is 256M-bytes
#define CMMPU_RGN_SIZE_512M (0x13U << 8U) //!< Region Size is 512M-bytes
#define CMMPU_RGN_SIZE_1G (0x14U << 8U) //!< Region Size is 1G-bytes
#define CMMPU_RGN_SIZE_2G (0x15U << 8U) //!< Region Size is 2G-bytes
#define CMMPU_RGN_SIZE_4G (0x16U << 8U) //!< Region Size is 4G-bytes
//*****************************************************************************
//
// Flags for the sub-region to be passed to CMMPU_setRegionAttributes().
//
//*****************************************************************************
#define CMMPU_SUB_RGN_DISABLE_0 0x00010000U //!< Disable sub-region 0
#define CMMPU_SUB_RGN_DISABLE_1 0x00020000U //!< Disable sub-region 1
#define CMMPU_SUB_RGN_DISABLE_2 0x00040000U //!< Disable sub-region 2
#define CMMPU_SUB_RGN_DISABLE_3 0x00080000U //!< Disable sub-region 3
#define CMMPU_SUB_RGN_DISABLE_4 0x00100000U //!< Disable sub-region 4
#define CMMPU_SUB_RGN_DISABLE_5 0x00200000U //!< Disable sub-region 5
#define CMMPU_SUB_RGN_DISABLE_6 0x00400000U //!< Disable sub-region 6
#define CMMPU_SUB_RGN_DISABLE_7 0x00800000U //!< Disable sub-region 7
//*****************************************************************************
//
// Mask for MPU region attributes to be used by CMMPU_setRegionAttributes().
//
//*****************************************************************************
#define CMMPU_RGN_CONFIG_M ((uint32_t)CMMPU_REGION0_CONFIG_ENABLE | \
(uint32_t)CMMPU_REGION0_CONFIG_PROT_TYPE_M | \
(uint32_t)CMMPU_REGION0_CONFIG_SIZE_M | \
(uint32_t)0xFF0000U)
//*****************************************************************************
//
// API Function prototypes
//
//*****************************************************************************
//*****************************************************************************
//
//! \internal
//! Checks the MPU module base address.
//!
//! \param base is the base address of the MPU instance used.
//!
//! This function determines if MPU module base address is valid. The paramater
//! \b base can take following values: DMPU_BASE, or EMPU_BASE.
//!
//! \return Returns \b true if the base address is valid and \b false
//! otherwise.
//
//*****************************************************************************
#ifdef DEBUG
static inline bool
CMMPU_isBaseValid(uint32_t base)
{
return((base == DMPU_BASE) || (base == EMPU_BASE));
}
#endif
//*****************************************************************************
//
//! Enables and configures the MPU for use.
//!
//! \param base is the base address of the MPU instance used.
//!
//! This function enables either the DMA or EMAC memory protection unit.
//! Prior to enabling the MPU, at least one region must be set by calling
//! CMMPU_setRegionAttributes(). Once the MPU is enabled, access violation
//! interrupts are generated if enabled.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_enable(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Enable the MPU.
//
HWREG(base + CMMPU_O_MPU_CONTROL_REG) |= CMMPU_MPU_CONTROL_REG_ENABLE;
}
//*****************************************************************************
//
//! Disables the MPU for use.
//!
//! \param base is the base address of the MPU instance used.
//!
//! This function disables either the DMA or EMAC memory protection unit.
//! When the MPU is disabled, the default memory map is used and access
//! violation interrupts are not generated.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_disable(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Turn off the MPU enable bit.
//
HWREG(base + CMMPU_O_MPU_CONTROL_REG) &= ~CMMPU_MPU_CONTROL_REG_ENABLE;
}
//*****************************************************************************
//
//! Enables the MPU RD/WR Access Violation Interrupts.
//!
//! \param base is the base address of the MPU instance used.
//!
//! This function enables either the DMA or EMAC MPU read/write access
//! violation interrupts.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_enableAccessViolationInterrupt(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Enable the interrupts.
//
HWREG(base + CMMPU_O_ACC_VIO_INTEN) = (CMMPU_ACC_VIO_INTEN_INTEN |
CMMPU_ACC_VIO_KEY);
}
//*****************************************************************************
//
//! Disables the MPU RD/WR Access Violation Interrupts.
//!
//! \param base is the base address of the MPU instance used.
//!
//! This function enables either the DMA or EMAC MPU read/write access
//! violation interrupts.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_disableAccessViolationInterrupt(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Disable the interrupts.
//
HWREG(base + CMMPU_O_ACC_VIO_INTEN) = (~CMMPU_ACC_VIO_INTEN_INTEN |
CMMPU_ACC_VIO_KEY);
}
//*****************************************************************************
//
//! Gets the status of MPU RD/WR Access Violation Interrupts.
//!
//! \param base is the base address of the MPU instance used.
//!
//! This function return the status of either the DMA or EMAC MPU read/write
//! access violation interrupts.
//!
//! \return Returns the access violation interrupt status. It can return
//! following values: CMMPU_ACC_VIO_FLAGS_READ, CMMPU_ACC_VIO_FLAGS_WRITE
//
//*****************************************************************************
static inline uint32_t
CMMPU_getAccessViolationFlags(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Return the access violation interrupts flag status.
//
return(HWREG(base + CMMPU_O_ACC_VIO_FLAGS));
}
//*****************************************************************************
//
//! Sets the MPU RD/WR Access Violation Interrupts.
//!
//! \param base is the base address of the MPU instance used.
//! \param flags is the flag for rd/wr violation.
//!
//! This function sets either the DMA or EMAC MPU read/write access
//! violation interrupts. The parameter \b flags can take following values:
//! CMMPU_ACC_VIO_FLAGS_READ, or CMMPU_ACC_VIO_FLAGS_WRITE.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_setAccessViolationFlags(uint32_t base, uint32_t flags)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Return the access violation interrupts flag status.
//
HWREG(base + CMMPU_O_ACC_VIO_FLAGS_SET) = (flags | CMMPU_ACC_VIO_KEY);
}
//*****************************************************************************
//
//! Clears the MPU RD/WR Access Violation Interrupt Status.
//!
//! \param base is the base address of the MPU instance used.
//! \param flags is the flag for rd/wr violation.
//!
//! This function clears either the DMA or EMAC MPU read/write access
//! violation interrupt status.The parameter \e flags can take following values:
//! CMMPU_ACC_VIO_FLAGS_READ, or CMMPU_ACC_VIO_FLAGS_WRITE.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_clearAccessViolationFlags(uint32_t base, uint32_t flags)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Clear the access violation interrupts flag status.
//
HWREG(base + CMMPU_O_ACC_VIO_FLAGS_CLR) = (flags | CMMPU_ACC_VIO_KEY);
}
//*****************************************************************************
//
//! Gets the MPU RD/WR Access Violation Address.
//!
//! \param base is the base address of the MPU instance used.
//!
//! This function enables either the DMA or EMAC MPU read/write access
//! violation interrupts.
//!
//! \return Returns the MPU RD/WR access violation address.
//
//*****************************************************************************
static inline uint32_t
CMMPU_getAccessViolationAddr(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
//
// Return the access violation address.
//
return(HWREG(base + CMMPU_O_ACC_VIO_ADDR_REG));
}
//*****************************************************************************
//
//! Sets up the access rules for a specific region.
//!
//! \param base is the base address of the MPU instance used.
//! \param regionNum is the region number to set up.
//! \param baseAddr is the base address of the region. It must be aligned
//! according to the size of the region specified in attrFlags.
//! \param attrFlags is a set of flags to define the attributes of the region.
//!
//! This function sets up the protection rules for a region. The region has
//! a base address and a set of attributes including the size.
//!
//! The region number parameter, \e regionNum specifies region number to setup.
//! Valid values for \e regionNum paramter are:
//! - \b CMMPU_RGN_0
//! - \b CMMPU_RGN_1
//! - \b CMMPU_RGN_2
//! - \b CMMPU_RGN_3
//! - \b CMMPU_RGN_4
//! - \b CMMPU_RGN_5
//! - \b CMMPU_RGN_6
//! - \b CMMPU_RGN_7
//!
//! The base address parameter, \e baseAddr, must be aligned according to the
//! size, and the size must be a power of 2.
//!
//! The \e attrFlags parameter is the logical OR of all of the attributes
//! of the region. It is a combination of choices for region size, read/write
//! permissions, disabled sub-regions, and a flag to determine if the region is
//! enabled.
//!
//! The size flag determines the size of a region and must be one of the
//! following:
//! - \b CMMPU_RGN_SIZE_1K
//! - \b CMMPU_RGN_SIZE_2K
//! - \b CMMPU_RGN_SIZE_4K
//! - \b CMMPU_RGN_SIZE_8K
//! - \b CMMPU_RGN_SIZE_16K
//! - \b CMMPU_RGN_SIZE_32K
//! - \b CMMPU_RGN_SIZE_64K
//! - \b CMMPU_RGN_SIZE_128K
//! - \b CMMPU_RGN_SIZE_256K
//! - \b CMMPU_RGN_SIZE_512K
//! - \b CMMPU_RGN_SIZE_1M
//! - \b CMMPU_RGN_SIZE_2M
//! - \b CMMPU_RGN_SIZE_4M
//! - \b CMMPU_RGN_SIZE_8M
//! - \b CMMPU_RGN_SIZE_16M
//! - \b CMMPU_RGN_SIZE_32M
//! - \b CMMPU_RGN_SIZE_64M
//! - \b CMMPU_RGN_SIZE_128M
//! - \b CMMPU_RGN_SIZE_256M
//! - \b CMMPU_RGN_SIZE_512M
//! - \b CMMPU_RGN_SIZE_1G
//! - \b CMMPU_RGN_SIZE_2G
//! - \b CMMPU_RGN_SIZE_4G
//!
//! The read/write access permission flag must be one of the following:
//! - \b CMMPU_RGN_PERM_READ_ONLY- read only permission to MPU region
//! - \b CMMPU_RGN_PERM_NO_ACCESS- disables read/write permission to MPU region
//! - \b CMMPU_RGN_PERM_FULL_ACCESS- read/write permission to MPU region
//!
//! The region is automatically divided into 8 equally-sized sub-regions by
//! the MPU. Sub-regions can only be used in regions of size 256 bytes
//! or larger. Any of these 8 sub-regions can be disabled, allowing for
//! creation of "holes" in a region which can be left open, or overlaid
//! by another region with different attributes. Any of the 8 sub-regions
//! can be disabled with a logical OR of any of the following flags:
//! - \b CMMPU_SUB_RGN_DISABLE_0
//! - \b CMMPU_SUB_RGN_DISABLE_1
//! - \b CMMPU_SUB_RGN_DISABLE_2
//! - \b CMMPU_SUB_RGN_DISABLE_3
//! - \b CMMPU_SUB_RGN_DISABLE_4
//! - \b CMMPU_SUB_RGN_DISABLE_5
//! - \b CMMPU_SUB_RGN_DISABLE_6
//! - \b CMMPU_SUB_RGN_DISABLE_7
//!
//! Finally, the region can be initially enabled or disabled with one of
//! the following flags:
//! - \b CMMPU_RGN_ENABLE
//! - \b CMMPU_RGN_DISABLE
//!
//! As an example, to set a region with the following attributes: size of
//! 32 KB, read-only access, one sub-region disabled, and initially enabled,
//! the \e attrFlags parameter would have the following value:
//! <code>
//! (CMMPU_RGN_SIZE_32K | CMMPU_RGN_PERM_READ_ONLY |
//! CMMPU_SUB_RGN_DISABLE_2 | CMMPU_RGN_ENABLE)
//! </code>
//!
//! \note This function writes to multiple registers and is not protected
//! from interrupts. It is possible that an interrupt which accesses a
//! region may occur while that region is in the process of being changed.
//! The safest way to handle this is to disable a region before changing it.
//! Refer to the discussion of this in the API Detailed Description section.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_setRegionAttributes(uint32_t base, uint32_t regionNum, uint32_t baseAddr,
uint32_t attrFlags)
{
uint32_t temp;
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
ASSERT(regionNum < 8U);
//
// Checking whether the region base address is aligned according to the
// desired region size.
//
ASSERT(baseAddr == (baseAddr & (~(uint32_t)0U << (((attrFlags &
CMMPU_REGION0_CONFIG_SIZE_M) >>
CMMPU_REGION0_CONFIG_SIZE_S) + 1U))));
//
// Program the region start address.
//
HWREG(base + CMMPU_O_REGION0_STARTADDRESSS + (regionNum * 8U)) = baseAddr;
//
// Program the region attributes.
//
temp = CMMPU_RGN_CONFIG_M;
HWREG(base + CMMPU_O_REGION0_CONFIG + (regionNum * 8U)) =
(HWREG(base + CMMPU_O_REGION0_CONFIG + (regionNum * 8U)) &
~(temp)) | attrFlags;
}
//*****************************************************************************
//
//! Gets the current settings for a specific region.
//!
//! \param base is the base address of the MPU instance used.
//! \param regionNum is the region number to get.
//! \param baseAddr points to storage for the base address of the region.
//! \param attrFlags points to the attribute flags for the region.
//!
//! This function retrieves the configuration of a specific region. The
//! meanings and format of the parameters is the same as that of the
//! CMMPU_setRegionAttributes() function.
//!
//! This function can be used to save the configuration of a region for later
//! use with the CMMPU_setRegionAttributes() function. The region's enable state
//! is preserved in the attributes that are saved.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_getRegionAttributes(uint32_t base, uint32_t regionNum, uint32_t *baseAddr,
uint32_t *attrFlags)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
ASSERT(regionNum < 8U);
ASSERT(baseAddr != 0x0U);
ASSERT(attrFlags != 0x0U);
//
// Read and store the start address for the region.
//
*baseAddr = HWREG(base + CMMPU_O_REGION0_STARTADDRESSS + (regionNum * 8U));
//
// Read and store the region attributes.
//
*attrFlags = HWREG(base + CMMPU_O_REGION0_CONFIG + (regionNum * 8U));
}
//*****************************************************************************
//
//! Enables a specific region.
//!
//! \param base is the base address of the MPU instance used.
//! \param regionNum is the region number to enable.
//!
//! This function is used to enable a memory protection region. The region
//! should already be configured with the CMMPU_setRegionAttributes() function.
//! Once enabled, the memory protection rules of the region are applied and
//! access violations cause a bus fault.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_enableRegion(uint32_t base, uint32_t regionNum)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
ASSERT(regionNum < 8U);
//
// Enable the region.
//
HWREG(base + CMMPU_O_REGION0_CONFIG + (regionNum * 8U)) |=
CMMPU_REGION0_CONFIG_ENABLE;
}
//*****************************************************************************
//
//! Disables a specific region.
//!
//! \param base is the base address of the MPU instance used.
//! \param regionNum is the region number to disable.
//!
//! This function is used to disable a previously enabled memory protection
//! region. The region remains configured if it is not overwritten with
//! another call to CMMPU_setRegionAttributes(), and can be enabled again by
//! calling CMMPU_enableRegion().
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_disableRegion(uint32_t base, uint32_t regionNum)
{
//
// Check the arguments.
//
ASSERT(CMMPU_isBaseValid(base));
ASSERT(regionNum < 8U);
//
// Modify the enable bit in the region attributes.
//
HWREG(base + CMMPU_O_REGION0_CONFIG + (regionNum * 8U)) &=
~CMMPU_REGION0_CONFIG_ENABLE;
}
//*****************************************************************************
//
//! Registers an interrupt handler for the memory management fault.
//!
//! \param intNum is the interrupt number to be registered.
//! \param fnHandler is a pointer to the function to be called when the
//! memory management fault occurs.
//!
//! This function sets and enables the handler to be called when the MPU
//! generates a bus fault due to a protection region access violation.
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_registerHandler(uint32_t intNum, void (*fnHandler)(void))
{
//
// Check the arguments.
//
ASSERT(fnHandler);
//
// Register the interrupt handler.
//
Interrupt_registerHandler(intNum, fnHandler);
//
// Enable the memory management fault.
//
Interrupt_enable(intNum);
}
//*****************************************************************************
//
//! Unregisters an interrupt handler for the memory management fault.
//!
//! \param intNum is the interrupt number to be unregistered.
//!
//! This function disables and clears the handler to be called when a
//! memory management fault occurs.
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CMMPU_unregisterHandler(uint32_t intNum)
{
//
// Disable the interrupt.
//
Interrupt_disable(intNum);
//
// Unregister the interrupt handler.
//
Interrupt_unregisterHandler(intNum);
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // CMMPU_H
@@ -0,0 +1,296 @@
//###########################################################################
//
// FILE: cpu.h
//
// TITLE: Instruction wrappers for special CPU instructions needed by the
// drivers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef CPU_H
#define CPU_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup cpu_api CPU
//! \brief The module is used for configuring Cortex-M core registers
//! @{
//
//*****************************************************************************
#include <stdint.h>
//
// Define for no operation
//
#ifndef NOP
#define NOP __asm(" NOP")
#endif
//*****************************************************************************
//
//! Returns the state of FAULTMASK register on entry and disable all
//! interrupts except NMI.
//!
//! This function is wrapper function for the CPSID instruction. It returns
//! the state of FAULTMASK on entry and disable all interrupts except NMI.
//!
//! \return Returns the state of FAULTMASK register.
//
//*****************************************************************************
static inline uint32_t
CPU_setFAULTMASK(void)
{
//
// Disable interrupts and return previous FAULTMASK.
//
return(_disable_interrupts());
}
//*****************************************************************************
//
//! Returns the state of FAULTMASK register
//!
//! This function is wrapper function for returning the state of FAULTMASK
//! register(indicating whether interrupts except NMI are enabled or disabled).
//!
//! \return Returns the state of FAULTMASK register.
//
//*****************************************************************************
static inline uint32_t
CPU_getFAULTMASK(void)
{
//
// Read FAULTMASK register.
//
__asm(" mrs r0, FAULTMASK\n"
" bx lr\n");
//
// The following keeps the compiler happy, because it wants to see a
// return value from this function. It will generate code to return
// a zero. However, the real return is the "bx lr" above, so the
// return(0) is never executed and the function returns with the value
// you expect in R0.
//
return(0U);
}
//*****************************************************************************
//
//! Returns the state of FAULTMASK register and enable the interrupts
//!
//! This function is wrapper function for returning the state of FAULTMASK
//! register and enabling the interrupts.
//!
//! \return Returns the state of FAULTMASK register.
//
//*****************************************************************************
static inline uint32_t
CPU_clearFAULTMASK(void)
{
//
// Enable interrupts and return previous FAULTMASK status.
//
return(_enable_interrupts());
}
//*****************************************************************************
//
//! Returns the state of PRIMASK register on entry and disable interrupts
//!
//! This function is wrapper function for the CPSID instruction. It returns
//! the state of PRIMASK on entry and disable interrupts.
//!
//! \return Returns the state of PRIMASK register.
//
//*****************************************************************************
static inline uint32_t
CPU_setPRIMASK(void)
{
//
// Read PRIMASK and Disable interrupts.
//
return(_disable_IRQ());
}
//*****************************************************************************
//
//! Returns the state of PRIMASK register
//!
//! This function is wrapper function for returning the state of PRIMASK
//! register(indicating whether interrupts are enabled or disabled).
//!
//! \return Returns the state of PRIMASK register.
//
//*****************************************************************************
static inline uint32_t
CPU_getPRIMASK(void)
{
//
// Return PRIMASK register status.
//
return(__get_PRIMASK());
}
//*****************************************************************************
//
//! Returns the state of PRIMASK register and enable the interrupts
//!
//! This function is wrapper function for returning the state of PRIMASK
//! register and enabling the interrupts.
//!
//! \return Returns the state of PRIMASK register.
//
//*****************************************************************************
static inline uint32_t
CPU_clearPRIMASK(void)
{
//
// Enable interrupts and return previous PRIMASK setting.
//
return(_enable_IRQ());
}
//*****************************************************************************
//
//! Wrapper function for the WFI instruction
//!
//! This function is wrapper function for the WFI instruction.
//!
//! \return None
//
//*****************************************************************************
static inline void
CPU_wfi(void)
{
//
// Wait for the next interrupt.
//
__asm(" wfi\n");
}
//*****************************************************************************
//
//! Writes the BASEPRI register
//!
//! \param basePriority is the value to be set
//!
//! This function is wrapper function for writing the BASEPRI register. MSB
//! 3-bits are enabled for setting the priority and non-implemented low-order
//! bits read as zero and ignore writes. To set the base priority of 0x2U,
//! the param \e basePriority to be passed should be 0x20U.
//!
//! \return None.
//
//*****************************************************************************
static inline void
CPU_setBASEPRI(uint32_t basePriority)
{
//
// Set the BASEPRI register
//
_set_interrupt_priority(basePriority);
}
//*****************************************************************************
//
//! Returns the state of BASEPRI register
//!
//! This function is wrapper function for reading the BASEPRI register.
//!
//! \return Returns the state of BASEPRI register
//
//*****************************************************************************
static inline uint32_t
CPU_getBASEPRI(void)
{
//
// Read BASEPRI register.
//
__asm(" mrs r0, BASEPRI\n"
" bx lr\n");
//
// The following keeps the compiler happy, because it wants to see a
// return value from this function. It will generate code to return
// a zero. However, the real return is the "bx lr" above, so the
// return(0) is never executed and the function returns with the value
// you expect in R0.
//
return(0U);
}
//*****************************************************************************
//
// Extern compiler intrinsic prototypes. See compiler User's Guide for details.
//
//*****************************************************************************
extern uint32_t __get_PRIMASK(void);
extern uint32_t _disable_interrupts(void);
extern uint32_t _enable_interrupts();
extern uint32_t _disable_IRQ();
extern uint32_t _enable_IRQ();
extern uint32_t _set_interrupt_priority(uint32_t priority);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // CPU_H
@@ -0,0 +1,61 @@
//#############################################################################
//
// FILE: cputimer.c
//
// TITLE: CM CPU timer Driver
//
//#############################################################################
//
// 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 "cputimer.h"
//*****************************************************************************
//
// CPUTimer_setEmulationMode
//
//*****************************************************************************
void CPUTimer_setEmulationMode(uint32_t base, CPUTimer_EmulationMode mode)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Write to FREE_SOFT bits of register TCR
//
HWREGH(base + CPUTIMER_O_TCR) =
(HWREGH(base + CPUTIMER_O_TCR) &
~(CPUTIMER_TCR_FREE | CPUTIMER_TCR_SOFT)) |
(uint16_t)mode;
}
@@ -0,0 +1,428 @@
//#############################################################################
//
// FILE: cputimer.h
//
// TITLE: CM CPU timer Driver
//
//#############################################################################
//
// 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.
// $
//#############################################################################
#ifndef CPUTIMER_H
#define CPUTIMER_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup cputimer_api CPUTimer
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_cputimer.h"
#include "debug.h"
#include "sysctl.h"
//*****************************************************************************
//
// Defines for the API.
//
//*****************************************************************************
//*****************************************************************************
//
//! Values that can be passed to CPUTimer_setEmulationMode() as the
//! \e mode parameter.
//
//****************************************************************************
typedef enum
{
//! Denotes that the timer will stop after the next decrement
CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT = 0x0000,
//! Denotes that the timer will stop when it reaches zero
CPUTIMER_EMULATIONMODE_STOPATZERO = 0x0400,
//! Denotes that the timer will run free
CPUTIMER_EMULATIONMODE_RUNFREE = 0x0800
}CPUTimer_EmulationMode;
//*****************************************************************************
//
//! The following are values that can be passed to
//! CPUTimer_selectClockSource() as the \e prescaler parameter.
//
//*****************************************************************************
typedef enum
{
CPUTIMER_CLOCK_PRESCALER_1 = 0, //!< Prescaler value of / 1
CPUTIMER_CLOCK_PRESCALER_2 = 1, //!< Prescaler value of / 2
CPUTIMER_CLOCK_PRESCALER_4 = 2, //!< Prescaler value of / 4
CPUTIMER_CLOCK_PRESCALER_8 = 3, //!< Prescaler value of / 8
CPUTIMER_CLOCK_PRESCALER_16 = 4 //!< Prescaler value of / 16
} CPUTimer_Prescaler;
//*****************************************************************************
//
//! \internal
//! Checks CPU timer base address.
//!
//! \param base specifies the Timer module base address.
//!
//! This function determines if a CPU timer module base address is valid.
//!
//! \return Returns \b true if the base address is valid and \b false
//! otherwise.
//
//*****************************************************************************
#ifdef DEBUG
static inline bool CPUTimer_isBaseValid(uint32_t base)
{
return((base == CPUTIMER0_BASE) || (base == CPUTIMER1_BASE) ||
(base == CPUTIMER2_BASE));
}
#endif
//*****************************************************************************
//
//! Clears CPU timer overflow flag.
//!
//! \param base is the base address of the timer module.
//!
//! This function clears the CPU timer overflow flag.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_clearOverflowFlag(uint32_t base)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Set TIF bit of TCR register
//
HWREGH(base + CPUTIMER_O_TCR) |= CPUTIMER_TCR_TIF;
}
//*****************************************************************************
//
//! Disables CPU timer interrupt.
//!
//! \param base is the base address of the timer module.
//!
//! This function disables the CPU timer interrupt.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_disableInterrupt(uint32_t base)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Clear TIE bit of TCR register
//
HWREGH(base + CPUTIMER_O_TCR) &= ~CPUTIMER_TCR_TIE;
}
//*****************************************************************************
//
//! Enables CPU timer interrupt.
//!
//! \param base is the base address of the timer module.
//!
//! This function enables the CPU timer interrupt.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_enableInterrupt(uint32_t base)
{
uint16_t tcrValue = 0;
ASSERT(CPUTimer_isBaseValid(base));
//
// Set TIE bit of TCR register
//
tcrValue = HWREGH(base + CPUTIMER_O_TCR) & (~CPUTIMER_TCR_TIF);
HWREGH(base + CPUTIMER_O_TCR) = tcrValue | CPUTIMER_TCR_TIE;
}
//*****************************************************************************
//
//! Reloads CPU timer counter.
//!
//! \param base is the base address of the timer module.
//!
//! This function reloads the CPU timer counter with the values contained in
//! the CPU timer period register.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_reloadTimerCounter(uint32_t base)
{
uint16_t tcrValue = 0;
ASSERT(CPUTimer_isBaseValid(base));
//
// Set TRB bit of register TCR
//
tcrValue = HWREGH(base + CPUTIMER_O_TCR) & (~CPUTIMER_TCR_TIF);
HWREGH(base + CPUTIMER_O_TCR) = tcrValue | CPUTIMER_TCR_TRB;
}
//*****************************************************************************
//
//! Stops CPU timer.
//!
//! \param base is the base address of the timer module.
//!
//! This function stops the CPU timer.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_stopTimer(uint32_t base)
{
uint16_t tcrValue = 0;
ASSERT(CPUTimer_isBaseValid(base));
//
// Set TSS bit of register TCR
//
tcrValue = HWREGH(base + CPUTIMER_O_TCR) & (~CPUTIMER_TCR_TIF);
HWREGH(base + CPUTIMER_O_TCR) = tcrValue | CPUTIMER_TCR_TSS;
}
//*****************************************************************************
//
//! Starts(restarts) CPU timer.
//!
//! \param base is the base address of the timer module.
//!
//! This function starts (restarts) the CPU timer.
//!
//! \b Note: This function doesn't reset the timer counter.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_resumeTimer(uint32_t base)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Clear TSS bit of register TCR
//
HWREGH(base + CPUTIMER_O_TCR) &= ~CPUTIMER_TCR_TSS;
}
//*****************************************************************************
//
//! Starts(restarts) CPU timer.
//!
//! \param base is the base address of the timer module.
//!
//! This function starts (restarts) the CPU timer.
//!
//! \b Note: This function reloads the timer counter.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_startTimer(uint32_t base)
{
uint16_t tcrValue = 0;
ASSERT(CPUTimer_isBaseValid(base));
//
// Reload the timer counter
//
tcrValue = HWREGH(base + CPUTIMER_O_TCR) & (~CPUTIMER_TCR_TIF);
HWREGH(base + CPUTIMER_O_TCR) = tcrValue | CPUTIMER_TCR_TRB;
//
// Clear TSS bit of register TCR
//
HWREGH(base + CPUTIMER_O_TCR) &= ~CPUTIMER_TCR_TSS;
}
//*****************************************************************************
//
//! Sets CPU timer period.
//!
//! \param base is the base address of the timer module.
//! \param periodCount is the CPU timer period count.
//!
//! This function sets the CPU timer period count.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_setPeriod(uint32_t base, uint32_t periodCount)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Load the MSB period Count
//
HWREG(base + CPUTIMER_O_PRD) = periodCount;
}
//*****************************************************************************
//
//! Returns the current CPU timer counter value.
//!
//! \param base is the base address of the timer module.
//!
//! This function returns the current CPU timer counter value.
//!
//! \return Returns the current CPU timer count value.
//
//*****************************************************************************
static inline uint32_t CPUTimer_getTimerCount(uint32_t base)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Get the TIMH:TIM registers value
//
return(HWREG(base + CPUTIMER_O_TIM));
}
//*****************************************************************************
//
//! Set CPU timer pre-scaler value.
//!
//! \param base is the base address of the timer module.
//! \param prescaler is the CPU timer pre-scaler value.
//!
//! This function sets the pre-scaler value for the CPU timer. For every value
//! of (prescaler + 1), the CPU timer counter decrements by 1.
//!
//! \return None.
//
//*****************************************************************************
static inline void CPUTimer_setPreScaler(uint32_t base, uint16_t prescaler)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Writes to TPR.TDDRL and TPR.TDDRH bits
//
HWREGH(base + CPUTIMER_O_TPR) = (prescaler & CPUTIMER_TPR_TDDRL_M);
HWREG(base + CPUTIMER_O_TPR) =
(HWREG(base + CPUTIMER_O_TPR) & ~CPUTIMER_TPR_TDDRH_M) |
(((uint32_t)prescaler << CPUTIMER_TPR_PSCL_S) & CPUTIMER_TPR_TDDRH_M);
}
//*****************************************************************************
//
//! Return the CPU timer overflow status.
//!
//! \param base is the base address of the timer module.
//!
//! This function returns the CPU timer overflow status.
//!
//! \return Returns true if the CPU timer has overflowed, false if not.
//
//*****************************************************************************
static inline bool CPUTimer_getTimerOverflowStatus(uint32_t base)
{
ASSERT(CPUTimer_isBaseValid(base));
//
// Check if TIF bits of register TCR are set
//
return(((HWREGH(base + CPUTIMER_O_TCR) & CPUTIMER_TCR_TIF) ==
CPUTIMER_TCR_TIF) ? true : false);
}
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! Sets Emulation mode for CPU timer.
//!
//! \param base is the base address of the timer module.
//! \param mode is the emulation mode of the timer.
//!
//! This function sets the behaviour of CPU timer during emulation. Valid
//! values mode are: CPUTIMER_EMULATIONMODE_STOPAFTERNEXTDECREMENT,
//! CPUTIMER_EMULATIONMODE_STOPATZERO and CPUTIMER_EMULATIONMODE_RUNFREE.
//!
//! \return None.
//
//*****************************************************************************
extern void CPUTimer_setEmulationMode(uint32_t base,
CPUTimer_EmulationMode mode);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // CPUTIMER_H
@@ -0,0 +1,368 @@
//#############################################################################
//
// FILE: dcsm.c
//
// TITLE: C28x Driver for the DCSM security module.
//
//#############################################################################
//
// 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 "dcsm.h"
//*****************************************************************************
//
// DCSM_writeZone1CSM
//
//*****************************************************************************
void
DCSM_writeZone1CSM(const DCSM_CSMPasswordKey * const psCMDKey)
{
//
// Check the arguments.
//
ASSERT(psCMDKey != NULL);
if(psCMDKey != NULL)
{
HWREG(DCSM_Z1_BASE + DCSM_O_Z1_CSMKEY0) = psCMDKey->csmKey0;
HWREG(DCSM_Z1_BASE + DCSM_O_Z1_CSMKEY1) = psCMDKey->csmKey1;
HWREG(DCSM_Z1_BASE + DCSM_O_Z1_CSMKEY2) = psCMDKey->csmKey2;
HWREG(DCSM_Z1_BASE + DCSM_O_Z1_CSMKEY3) = psCMDKey->csmKey3;
}
}
//*****************************************************************************
//
// DCSM_writeZone2CSM
//
//*****************************************************************************
void
DCSM_writeZone2CSM(const DCSM_CSMPasswordKey * const psCMDKey)
{
//
// Check the arguments.
//
ASSERT(psCMDKey != NULL);
if(psCMDKey != NULL)
{
HWREG(DCSM_Z2_BASE + DCSM_O_Z2_CSMKEY0) = psCMDKey->csmKey0;
HWREG(DCSM_Z2_BASE + DCSM_O_Z2_CSMKEY1) = psCMDKey->csmKey1;
HWREG(DCSM_Z2_BASE + DCSM_O_Z2_CSMKEY2) = psCMDKey->csmKey2;
HWREG(DCSM_Z2_BASE + DCSM_O_Z2_CSMKEY3) = psCMDKey->csmKey3;
}
}
//*****************************************************************************
//
// DCSM_getZone1FlashEXEStatus
//
//*****************************************************************************
DCSM_EXEOnlyStatus
DCSM_getZone1FlashEXEStatus(DCSM_Sector sector, DCSM_CPUSel cpuInst)
{
uint16_t regValue;
uint32_t regintValue;
DCSM_EXEOnlyStatus status;
//
// Check if sector belongs to this zone
//
if(DCSM_getFlashSectorZone(sector, cpuInst) != DCSM_MEMORY_ZONE1)
{
status = DCSM_INCORRECT_ZONE;
}
else
{
//
// Get the EXE status register
//
if(cpuInst == DCSM_CPUSEL_CPU1)
{
regintValue = ((HWREG(DCSM_Z1_BASE + DCSM_O_Z1_EXEONLYSECT1R)) &
DCSM_EXEONLYSECTR_M);
regValue = (uint16_t)regintValue;
}
else if(cpuInst == DCSM_CPUSEL_CM)
{
regintValue = ((HWREG(DCSM_Z1_BASE + DCSM_O_Z1_EXEONLYSECT1R))
>> DCSM_EXEONLYSECTR_S);
regValue = (uint16_t)regintValue;
}
else
{
regValue = (HWREGH(DCSM_Z1_BASE + DCSM_O_Z1_EXEONLYSECT2R));
}
//
// Get the EXE status of the Flash Sector
//
status = (DCSM_EXEOnlyStatus)((uint16_t)
((regValue >> (uint16_t)sector) &
0x01U));
}
return(status);
}
//*****************************************************************************
//
// DCSM_getZone1RAMEXEStatus
//
//*****************************************************************************
DCSM_EXEOnlyStatus
DCSM_getZone1RAMEXEStatus(DCSM_RAMModule module, DCSM_CPUSel cpuInst)
{
uint32_t status;
uint16_t moduleCM = 0U;
ASSERT(cpuInst <= DCSM_CPUSEL_CPU2);
if((cpuInst == DCSM_CPUSEL_CPU1) || (cpuInst == DCSM_CPUSEL_CPU2))
{
ASSERT(module < DCSM_C28_RAM_END);
}
if(cpuInst == DCSM_CPUSEL_CM)
{
ASSERT((module > DCSM_C28_RAM_END) &&
(module < DCSM_CM_RAM_END));
moduleCM = (uint16_t)module - ((uint16_t)DCSM_C28_RAM_END + 1U);
}
//
// Check if module belongs to this zone
//
if(DCSM_getRAMZone(module, cpuInst) != DCSM_MEMORY_ZONE1)
{
status = DCSM_INCORRECT_ZONE;
}
else
{
//
// Get the EXE status of the RAM Module
//
if(cpuInst == DCSM_CPUSEL_CPU1)
{
status = (uint16_t)((HWREGH(DCSM_Z1_BASE +
DCSM_O_Z1_EXEONLYRAM1R) >>
(uint16_t)module) & 0x01U);
}
else if(cpuInst == DCSM_CPUSEL_CM)
{
status = ((HWREG(DCSM_Z1_BASE + DCSM_O_Z1_EXEONLYRAM1R) >>
(DCSM_Z1_EXEONLYRAM1R_CM + moduleCM)) & 0x01UL);
}
else
{
status = ((HWREG(DCSM_Z1_BASE + DCSM_O_Z1_EXEONLYRAM1R) >>
(DCSM_Z1_EXEONLYRAM1R_CPU2 - (uint16_t)module)) & 0x01U);
}
}
return((DCSM_EXEOnlyStatus)status);
}
//*****************************************************************************
//
// DCSM_getZone2FlashEXEStatus
//
//*****************************************************************************
DCSM_EXEOnlyStatus
DCSM_getZone2FlashEXEStatus(DCSM_Sector sector, DCSM_CPUSel cpuInst)
{
uint16_t regValue;
uint32_t regintValue;
DCSM_EXEOnlyStatus status;
//
// Check if sector belongs to this zone
//
if(DCSM_getFlashSectorZone(sector, cpuInst) != DCSM_MEMORY_ZONE2)
{
status = DCSM_INCORRECT_ZONE;
}
else
{
//
// Get the EXE status register
//
if(cpuInst == DCSM_CPUSEL_CPU1)
{
regintValue = ((HWREG(DCSM_Z2_BASE +
DCSM_O_Z2_EXEONLYSECT1R)) &
DCSM_EXEONLYSECTR_M);
regValue = (uint16_t)regintValue;
}
else if(cpuInst == DCSM_CPUSEL_CM)
{
regintValue = ((HWREG(DCSM_Z2_BASE + DCSM_O_Z2_EXEONLYSECT1R))
>> DCSM_EXEONLYSECTR_S);
regValue = (uint16_t)regintValue;
}
else
{
regValue = HWREGH(DCSM_Z2_BASE + DCSM_O_Z2_EXEONLYSECT2R);
}
//
// Get the EXE status of the Flash Sector
//
status = (DCSM_EXEOnlyStatus)((uint16_t)((regValue >>
(uint16_t)sector) & 0x01U));
}
return(status);
}
//*****************************************************************************
//
// DCSM_getZone2RAMEXEStatus
//
//*****************************************************************************
DCSM_EXEOnlyStatus
DCSM_getZone2RAMEXEStatus(DCSM_RAMModule module, DCSM_CPUSel cpuInst)
{
uint32_t status;
uint16_t moduleCM = 0U;
ASSERT(cpuInst <= DCSM_CPUSEL_CPU2);
if((cpuInst == DCSM_CPUSEL_CPU1) || (cpuInst == DCSM_CPUSEL_CPU2))
{
ASSERT(module < DCSM_C28_RAM_END);
}
if(cpuInst == DCSM_CPUSEL_CM)
{
ASSERT((module > DCSM_C28_RAM_END) &&
(module < DCSM_CM_RAM_END));
moduleCM = (uint16_t)module - ((uint16_t)DCSM_C28_RAM_END + 1U);
}
//
// Check if module belongs to this zone
//
if(DCSM_getRAMZone(module, cpuInst) != DCSM_MEMORY_ZONE2)
{
status = DCSM_INCORRECT_ZONE;
}
else
{
//
// Get the EXE status of the RAM Module
//
if(cpuInst == DCSM_CPUSEL_CPU1)
{
status = (uint16_t)((HWREGH(DCSM_Z2_BASE +
DCSM_O_Z2_EXEONLYRAM1R) >>
(uint16_t)module) & 0x01U);
}
else if(cpuInst == DCSM_CPUSEL_CM)
{
status = ((HWREG(DCSM_Z2_BASE + DCSM_O_Z2_EXEONLYRAM1R) >>
(DCSM_Z2_EXEONLYRAM1R_CM + moduleCM)) & 0x01U);
}
else
{
status = ((HWREG(DCSM_Z2_BASE + DCSM_O_Z2_EXEONLYRAM1R) >>
(DCSM_Z2_EXEONLYRAM1R_CPU2 - (uint16_t)module)) &
0x01U);
}
}
return((DCSM_EXEOnlyStatus)status);
}
//*****************************************************************************
//
// DCSM_claimZoneSemaphore
//
//*****************************************************************************
bool
DCSM_claimZoneSemaphore(DCSM_SemaphoreZone zone)
{
//
// FLSEM register address.
//
uint32_t regAddress = DCSMCOMMON_BASE + DCSM_O_FLSEM;
//
// Write 0xA5 to the key and write the zone that is attempting to claim the
// Flash Pump Semaphore to the semaphore bits.
//
HWREGH(regAddress) = ((uint16_t)FLSEM_KEY << DCSM_FLSEM_KEY_S) |
(uint16_t)zone;
//
// If the calling function was unable to claim the zone semaphore, then
// return false
//
return(((HWREGH(regAddress) & DCSM_FLSEM_SEM_M) == (uint16_t)zone) ?
true : false);
}
//*****************************************************************************
//
// DCSM_releaseZoneSemaphore
//
//*****************************************************************************
bool
DCSM_releaseZoneSemaphore(void)
{
//
// FLSEM register address.
//
uint32_t regAddress = DCSMCOMMON_BASE + DCSM_O_FLSEM;
//
// Write 0xA5 to the key and write the zone that is attempting to claim the
// Flash Pump Semaphore to the semaphore bits.
//
HWREGH(regAddress) = ((uint16_t)FLSEM_KEY << DCSM_FLSEM_KEY_S);
//
// If the calling function was unable to release the zone semaphore, then
// return false
//
return(((HWREGH(regAddress) & DCSM_FLSEM_SEM_M) == 0x0U) ? true : false);
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,74 @@
//###########################################################################
//
// FILE: debug.h
//
// TITLE: Assert definition macro for debug.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef __DEBUG_H__
#define __DEBUG_H__
//*****************************************************************************
//
// Prototype for the function that is called when an invalid argument is passed
// to an API. This is only used when doing a DEBUG build. It is the
// application's responsibility to define the __error__ function.
//
//*****************************************************************************
extern void __error__(const char *filename, uint32_t line);
//*****************************************************************************
//
// The ASSERT macro, which does the actual assertion checking. Typically, this
// will be for procedure arguments.
//
//*****************************************************************************
#ifdef DEBUG
#define ASSERT(expr) do \
{ \
if(!(expr)) \
{ \
__error__(__FILE__, __LINE__); \
} \
} \
while(0)
#else
#define ASSERT(expr)
#endif
#endif // __DEBUG_H__
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,180 @@
//###########################################################################
//
// FILE: flash.c
//
// TITLE: CM Flash driver.
//
//###########################################################################
//
// 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 "flash.h"
#ifndef __cplusplus
#pragma CODE_SECTION(Flash_initModule, ".TI.ramfunc");
#pragma CODE_SECTION(Flash_powerDown, ".TI.ramfunc");
#pragma CODE_SECTION(Flash_wakeFromLPM, ".TI.ramfunc");
#endif
//*****************************************************************************
//
// Flash_initModule
//
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#endif
void
Flash_initModule(uint32_t ctrlBase, uint32_t eccBase, uint16_t waitstates)
{
volatile uint32_t count;
//
// Check the arguments.
//
ASSERT(Flash_isCtrlBaseValid(ctrlBase));
ASSERT(Flash_isECCBaseValid(eccBase));
ASSERT(waitstates <= 0xFU);
//
// Unlock to enable the writes to the flash control and ECC registers.
//
Flash_unlockCtrlRegisters(ctrlBase);
Flash_unlockECCRegisters(eccBase);
//
// Set the bank fallback power mode to active.
//
Flash_setBankPowerMode(ctrlBase, FLASH_BANK, FLASH_BANK_PWR_ACTIVE);
//
// Power up flash bank and pump and this also sets the fall back mode of
// flash and pump as active
//
Flash_setPumpPowerMode(ctrlBase, FLASH_PUMP_PWR_ACTIVE);
//
// Disable cache and prefetch mechanism before changing wait states
//
Flash_disableDataCache(ctrlBase);
Flash_disableProgramCache(ctrlBase);
//
// Set waitstates according to frequency.
//
Flash_setWaitstates(ctrlBase, waitstates);
//
// Enable cache and prefetch mechanism to improve performance of code
// executed from flash.
//
Flash_enableDataCache(ctrlBase);
Flash_enableProgramCache(ctrlBase);
//
// At reset, ECC is enabled. If it is disabled by application software and
// if application again wants to enable ECC.
//
Flash_enableECC(eccBase);
//
// Force a pipeline flush to ensure that the write to the last register
// configured occurs before returning.
//
for(count = 0U; count < 8U; count++)
{
NOP;
}
}
//*****************************************************************************
//
// Flash_powerDown
//
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#endif
void
Flash_powerDown(uint32_t ctrlBase)
{
//
// Check the arguments.
//
ASSERT(Flash_isCtrlBaseValid(ctrlBase));
//
// Unlock to enable the writes to the flash control registers.
//
Flash_unlockCtrlRegisters(ctrlBase);
//
// Power down the flash bank.
//
Flash_setBankPowerMode(ctrlBase, FLASH_BANK, FLASH_BANK_PWR_SLEEP);
//
// Power down the flash pump.
//
Flash_setPumpPowerMode(ctrlBase, FLASH_PUMP_PWR_SLEEP);
}
//*****************************************************************************
//
// Flash_wakeFromLPM
//
//*****************************************************************************
#ifdef __cplusplus
#pragma CODE_SECTION(".TI.ramfunc");
#endif
void
Flash_wakeFromLPM(uint32_t ctrlBase)
{
//
// Check the arguments.
//
ASSERT(Flash_isCtrlBaseValid(ctrlBase));
//
// Set the bank fallback power modes to active.
//
Flash_setBankPowerMode(ctrlBase, FLASH_BANK, FLASH_BANK_PWR_ACTIVE);
//
// Set the flash pump power mode to active.
//
Flash_setPumpPowerMode(ctrlBase, FLASH_PUMP_PWR_ACTIVE);
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,119 @@
//###########################################################################
//
// FILE: gcrc.c
//
// TITLE: Driver for the GCRC module.
//
//###########################################################################
//
// 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 "gcrc.h"
//*****************************************************************************
//
// GCRC_setFixedPolynomialDataPath()
//
//*****************************************************************************
void
GCRC_setFixedPolynomialDataPath(uint32_t base)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
//
// Set the polynomial size, Endianness, dataType and Bitreverse fields
//
HWREG(base + GCRC_O_CRCCTRL) = ((uint32_t)GCRC_FIXEDPATH_POLYSIZE <<
GCRC_CRCCTRL_POLYSIZE_S) |
GCRC_FIXEDPATH_ENDIANNESS |
GCRC_FIXEDPATH_DATATYPE |
GCRC_FIXEDPATH_BITREVERSE;
//
// Set the 32-bit polynomial
//
HWREG(base + GCRC_O_CRCPOLY) = GCRC_FIXEDPATH_POLY;
//
// Disable data masking
//
HWREG(base + GCRC_O_CRCDATAMASK) = GCRC_FIXEDPATH_DATAMASK;
}
//*****************************************************************************
//
// GCRC_writeData()
//
//*****************************************************************************
void
GCRC_writeData(uint32_t base, uint32_t data, uint32_t dataSize)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
ASSERT((dataSize == GCRC_DATATYPE_8BIT) ||
(dataSize == GCRC_DATATYPE_16BIT) ||
(dataSize == GCRC_DATATYPE_32BIT));
if(dataSize == GCRC_DATATYPE_8BIT)
{
//
// Perform a 8-bit write
//
HWREGB(base + GCRC_O_CRCDATAIN) = (uint8_t)data;
}
else if(dataSize == GCRC_DATATYPE_16BIT)
{
//
// Perform a 16-bit write
//
HWREGH(base + GCRC_O_CRCDATAIN) = (uint16_t)data;
}
else
{
//
// Perform a 32-bit write
//
HWREG(base + GCRC_O_CRCDATAIN) = data;
}
}
@@ -0,0 +1,441 @@
//###########################################################################
//
// FILE: gcrc.h
//
// TITLE: Driver for the GCRC module.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef GCRC_H
#define GCRC_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup gcrc_api GCRC
//! \brief This module is used for CRC calculations using GCRC.
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "debug.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_gcrc.h"
//*****************************************************************************
//
// Defines for the API.
//
//*****************************************************************************
//*****************************************************************************
//
// GCRC endianness values that can be passed to GCRC_setDataEndianness()
// Endianness applies to word and half word writes.
//
//*****************************************************************************
#define GCRC_ENDIANNESS_LITTLE 0x00000000U //!< Little Endian
#define GCRC_ENDIANNESS_BIG 0x00000040U //!< Big Endian
//*****************************************************************************
//
// GCRC data types that can be passed as datatype param to GCRC_setDataType()
// and datasize param to GCRC_writeData()
//
//*****************************************************************************
#define GCRC_DATATYPE_8BIT 0x00000000U //!< Byte data type
#define GCRC_DATATYPE_16BIT 0x00000100U //!< 16-bit data type
#define GCRC_DATATYPE_32BIT 0x00000200U //!< 32 bit data type
//*****************************************************************************
//
// GCRC configuration for fixed polynomial path
//
//*****************************************************************************
#define GCRC_FIXEDPATH_POLY 0x04c11db7U //!< 32 bit polynomial
#define GCRC_FIXEDPATH_POLYSIZE 0x00000020U //!< 32 bit polynomial
#define GCRC_FIXEDPATH_ENDIANNESS GCRC_ENDIANNESS_LITTLE //!< Little Endian
#define GCRC_FIXEDPATH_BITREVERSE 0U //!< No bit reversal
#define GCRC_FIXEDPATH_DATATYPE GCRC_DATATYPE_32BIT //!< 32 bit datatype
#define GCRC_FIXEDPATH_DATAMASK 0U //!< No masking
#define GCRC_POLYSIZE_MAXVALUE 0x20U //!< Max value possible for POLYSIZE
//!< field in CRCCTRL register
//*****************************************************************************
//
// API Function prototypes
//
//*****************************************************************************
//*****************************************************************************
//
//! \internal
//! Checks GCRC base address.
//!
//! \param base is the base address of the GCRC instance used.
//!
//! This function determines if GCRC module base address is valid.
//!
//! \return Returns \b true if the base address is valid and \b false
//! otherwise.
//
//*****************************************************************************
#ifdef DEBUG
static inline bool
GCRC_isBaseValid(uint32_t base)
{
return(base == GCRC_BASE);
}
#endif
//*****************************************************************************
//
//! Sets the generator polynomial.
//!
//! \param base is the base address of the GCRC instance used
//! \param poly is the generator polynomial
//! \param polySize is the order of the polynomial (1 - 32)
//!
//! This function sets the generator polynomial for computing CRC.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GCRC_setPolynomial(uint32_t base, uint32_t poly, uint32_t polySize)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
ASSERT((polySize != 0U) && (polySize <= GCRC_POLYSIZE_MAXVALUE));
//
// Set the polynomial size
//
HWREG(base + GCRC_O_CRCCTRL) = (polySize << GCRC_CRCCTRL_POLYSIZE_S) |
(HWREG(base + GCRC_O_CRCCTRL) &
~(uint32_t)GCRC_CRCCTRL_POLYSIZE_M);
//
// Set the polynomial
//
HWREG(base + GCRC_O_CRCPOLY) = poly;
}
//*****************************************************************************
//
//! Sets the endianness of the data.
//!
//! \param base is the base address of the GCRC instance used
//! \param endianness is the data endianness. Use macros
//! GCRC_ENDIANNESS_LITTLE or GCRC_ENDIANNESS_BIG
//!
//! This function sets the endianness of the data.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GCRC_setDataEndianness(uint32_t base, uint32_t endianness)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
ASSERT((endianness == GCRC_ENDIANNESS_LITTLE) ||
(endianness == GCRC_ENDIANNESS_BIG));
//
// Set the endianness in the control register
//
HWREG(base + GCRC_O_CRCCTRL) = (HWREG(base + GCRC_O_CRCCTRL) &
~(uint32_t)GCRC_CRCCTRL_ENDIANNESS) |
endianness;
}
//*****************************************************************************
//
//! Sets the datatype of the data.
//!
//! \param base is the base address of the GCRC instance used
//! \param dataType is the data type of the input data. Use macros
//! GCRC_DATATYPE_8BIT, GCRC_DATATYPE_16BIT, GCRC_DATATYPE_32BIT
//!
//! This function set the data type of the element of the data array,
//! on which CRC is to be computed..
//!
//! \return None.
//
//*****************************************************************************
static inline void
GCRC_setDataType(uint32_t base, uint32_t dataType)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
ASSERT((dataType == GCRC_DATATYPE_8BIT) ||
(dataType == GCRC_DATATYPE_16BIT) ||
(dataType == GCRC_DATATYPE_32BIT));
//
// Set the data type in the control register
//
HWREG(base + GCRC_O_CRCCTRL) = (HWREG(base + GCRC_O_CRCCTRL) &
~(uint32_t)GCRC_CRCCTRL_DATATYPE_M) |
dataType;
}
//*****************************************************************************
//
//! Enable/Disable bit reverse feature.
//!
//! \param base is the base address of the GCRC instance used
//! \param enable : TRUE if bit reverse needs to be enabled.
//! : FALSE if bit reverse needs to be disabled
//!
//! This function enables/disables the bit reverse of the input data
//!
//! \return None.
//
//*****************************************************************************
static inline void
GCRC_enableBitReverse(uint32_t base, bool enable)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
if(enable)
{
//
// Set the bit reverse bit in control register
//
HWREG(base + GCRC_O_CRCCTRL) |= GCRC_CRCCTRL_BITREVERSE;
}
else
{
//
// Clear the bit reverse bit in the control register
//
HWREG(base + GCRC_O_CRCCTRL) &= ~GCRC_CRCCTRL_BITREVERSE;
}
}
//*****************************************************************************
//
//! Sets the data mask for the input data.
//!
//! \param base is the base address of the GCRC instance used
//! \param dataMask is the number of bits to be masked.
//!
//! This function set the data mask for the input data.
//! For example, dataMask equals 0x3, 3 most significant bits of data will
//! be masked.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GCRC_setDataMask(uint32_t base, uint32_t dataMask)
{
#ifdef DEBUG
uint32_t dataType = HWREG(base + GCRC_O_CRCCTRL) & GCRC_CRCCTRL_DATATYPE_M;
#endif
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
ASSERT(((dataType == GCRC_DATATYPE_8BIT) && (dataMask < 8U)) ||
((dataType == GCRC_DATATYPE_16BIT) && (dataMask < 16U)) ||
((dataType == GCRC_DATATYPE_32BIT) && (dataMask < 32U)));
//
// Set the DATAMASK register
//
HWREG(base + GCRC_O_CRCDATAMASK) = dataMask;
}
//*****************************************************************************
//
//! Sets the seed value.
//!
//! \param base is the base address of the GCRC instance used
//! \param value is the seed value that needs to be set.
//!
//! This function sets the seed value for CRC computation.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GCRC_setSeedValue(uint32_t base, uint32_t value)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
//
// Set the DATAOUT register with seed value
//
HWREG(base + GCRC_O_CRCDATAOUT) = value;
}
//*****************************************************************************
//
//! Reads the computed CRC value.
//!
//! \param base is the base address of the GCRC instance used
//!
//! This function read the computed CRC value.
//!
//! \note Reads from CRCDATAOUT register will be stalled if CRC engine is
//! busy computing CRC
//!
//! \return None.
//
//*****************************************************************************
static inline uint32_t
GCRC_readResult(uint32_t base)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
return(HWREG(base + GCRC_O_CRCDATAOUT));
}
//*****************************************************************************
//
//! Reads the transformed data
//!
//! \param base is the base address of the GCRC instance used
//!
//! This function returns the data value as seen by the core CRC engine after
//! endianess, bit reversal and masking transformation
//!
//! \return None.
//
//*****************************************************************************
static inline uint32_t
GCRC_getTransData(uint32_t base)
{
//
// Check the arguments
//
ASSERT(GCRC_isBaseValid(base));
return(HWREG(base + GCRC_O_CRCDATATRANS));
}
//*****************************************************************************
//
//! Sets the fixed polynomial data path.
//!
//! \param base is the base address of the GCRC instance used
//!
//! This function sets the fixed polynomial data path which computes
//! the CRC in a single cycle.
//!
//! \note Only 32-bit writes. Byte and halfword accesses would take the
//! generic CRC data path.
//!
//! \return None.
//
//*****************************************************************************
extern void
GCRC_setFixedPolynomialDataPath(uint32_t base);
//*****************************************************************************
//
//! Writes the input data.
//!
//! \param base is the base address of the GCRC instance used
//! \param data is value that needs to be written.
//! \param dataSize is the size of the data. Use macros GCRC_DATATYPE_8BIT,
//! GCRC_DATATYPE_16BIT, GCRC_DATATYPE_32BIT
//!
//! This function writes the input data for the CRC computation.
//!
//! \note Writes to CRCDATAIN register will be stalled if CRC engine is
//! busy computing CRC
//!
//! \return None.
//
//*****************************************************************************
extern void
GCRC_writeData(uint32_t base, uint32_t data, uint32_t dataSize);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // GCRC_H
@@ -0,0 +1,44 @@
//###########################################################################
//
// FILE: gpio.c
//
// TITLE: CM GPIO driver.
//
//###########################################################################
//
// 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 "gpio.h"
@@ -0,0 +1,488 @@
//###########################################################################
//
// FILE: gpio.h
//
// TITLE: CM GPIO driver.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef GPIO_H
#define GPIO_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup gpio_api GPIO
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_gpio.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "debug.h"
//*****************************************************************************
//
// Useful defines used within the driver functions to access gpio registers.
// Not intended for use by application code.
//
// Divide by 4 is for CM which has byte access
//
//*****************************************************************************
#define GPIO_DATA_REGS_STEP ((GPIO_O_GPBDAT - GPIO_O_GPADAT) / 4U)
#define GPIO_DATA_READ_REGS_STEP ((GPIO_O_GPBDAT_R - GPIO_O_GPADAT_R) / 4U)
#define GPIO_GPxDAT_INDEX (GPIO_O_GPADAT / 4U)
#define GPIO_GPxSET_INDEX (GPIO_O_GPASET / 4U)
#define GPIO_GPxCLEAR_INDEX (GPIO_O_GPACLEAR / 4U)
#define GPIO_GPxTOGGLE_INDEX (GPIO_O_GPATOGGLE / 4U)
#define GPIO_GPxDAT_R_INDEX (GPIO_O_GPADAT_R / 4U)
#ifndef DOXYGEN_PDF_IGNORE
//*****************************************************************************
//
// Values that can be passed to GPIO_setPadConfig() as the pinType parameter
// and returned by GPIO_getPadConfig().
//
//*****************************************************************************
#define GPIO_PIN_TYPE_STD 0x0000U //!< Push-pull output or floating input
#define GPIO_PIN_TYPE_PULLUP 0x0001U //!< Pull-up enable for input
#define GPIO_PIN_TYPE_INVERT 0x0002U //!< Invert polarity on input
#define GPIO_PIN_TYPE_OD 0x0004U //!< Open-drain on output
#endif
//*****************************************************************************
//
//! Values that can be passed to GPIO_readPortData(), GPIO_setPortPins(),
//! GPIO_clearPortPins(), and GPIO_togglePortPins() as the \e port parameter.
//
//*****************************************************************************
typedef enum
{
GPIO_PORT_A = 0, //!< GPIO port A
GPIO_PORT_B = 1, //!< GPIO port B
GPIO_PORT_C = 2, //!< GPIO port C
GPIO_PORT_D = 3, //!< GPIO port D
GPIO_PORT_E = 4, //!< GPIO port E
GPIO_PORT_F = 5 //!< GPIO port F
} GPIO_Port;
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \internal
//! Checks that a pin number is valid for a device.
//!
//! Note that this function reflects the highest possible GPIO number of a
//! device on its biggest package. Check the datasheet to see what the actual
//! range of valid pin numbers is for a specific package.
//!
//! \return None.
//
//*****************************************************************************
#ifdef DEBUG
static inline bool
GPIO_isPinValid(uint32_t pin)
{
return(pin <= 168U);
}
#endif
//*****************************************************************************
//
//! Reads the value present on the specified pin.
//!
//! \param pin is the identifying GPIO number of the pin.
//!
//! The value at the specified pin are read, as specified by \e pin. The value
//! is returned for both input and output pins.
//!
//! The pin is specified by its numerical value. For example, GPIO34 is
//! specified by passing 34 as \e pin.
//!
//! \return Returns the value in the data register for the specified pin.
//
//*****************************************************************************
static inline uint32_t
GPIO_readPin(uint32_t pin)
{
volatile uint32_t *gpioDataReg;
//
// Check the arguments.
//
ASSERT(GPIO_isPinValid(pin));
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((pin / 32U) * GPIO_DATA_REGS_STEP);
return((gpioDataReg[GPIO_GPxDAT_INDEX] >> (pin % 32U)) & (uint32_t)0x1U);
}
//*****************************************************************************
//
//! Reads the data register value for specified pin.
//!
//! \param pin is the identifying GPIO number of the pin.
//!
//! The value available at the data register for the specified pin is read, as
//! specified by \e pin. The value is returned for both input and output pins.
//!
//! The pin is specified by its numerical value. For example, GPIO34 is
//! specified by passing 34 as \e pin.
//!
//! \sa GPIO_readPin()
//!
//! \return Returns the value in the data register for the specified pin.
//
//*****************************************************************************
static inline uint32_t
GPIO_readPinDataRegister(uint32_t pin)
{
volatile uint32_t *gpioDataReg;
//
// Check the arguments.
//
ASSERT(GPIO_isPinValid(pin));
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATAREAD_BASE) +
((pin / 32U) * GPIO_DATA_READ_REGS_STEP);
return((gpioDataReg[GPIO_GPxDAT_R_INDEX] >> (pin % 32U)) & (uint32_t)0x1U);
}
//*****************************************************************************
//
//! Writes a value to the specified pin.
//!
//! \param pin is the identifying GPIO number of the pin.
//! \param outVal is the value to write to the pin.
//!
//! Writes the corresponding bit values to the output pin specified by
//! \e pin. Writing to a pin configured as an input pin has no effect.
//!
//! The pin is specified by its numerical value. For example, GPIO34 is
//! specified by passing 34 as \e pin.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GPIO_writePin(uint32_t pin, uint32_t outVal)
{
volatile uint32_t *gpioDataReg;
uint32_t pinMask;
//
// Check the arguments.
//
ASSERT(GPIO_isPinValid(pin));
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((pin / 32U) * GPIO_DATA_REGS_STEP);
pinMask = (uint32_t)1U << (pin % 32U);
if(outVal == 0U)
{
gpioDataReg[GPIO_GPxCLEAR_INDEX] = pinMask;
}
else
{
gpioDataReg[GPIO_GPxSET_INDEX] = pinMask;
}
}
//*****************************************************************************
//
//! Toggles the specified pin.
//!
//! \param pin is the identifying GPIO number of the pin.
//!
//! Writes the corresponding bit values to the output pin specified by
//! \e pin. Writing to a pin configured as an input pin has no effect.
//!
//! The pin is specified by its numerical value. For example, GPIO34 is
//! specified by passing 34 as \e pin.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GPIO_togglePin(uint32_t pin)
{
volatile uint32_t *gpioDataReg;
//
// Check the arguments.
//
ASSERT(GPIO_isPinValid(pin));
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((pin / 32U) * GPIO_DATA_REGS_STEP);
gpioDataReg[GPIO_GPxTOGGLE_INDEX] = (uint32_t)1U << (pin % 32U);
}
//*****************************************************************************
//
//! Reads the data on the specified port.
//!
//! \param port is the GPIO port being accessed in the form of \b GPIO_PORT_X
//! where X is the port letter.
//!
//! \return Returns the value available on pin for the specified port. Each
//! bit of the the return value represents a pin on the port, where bit 0
//! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
//
//*****************************************************************************
static inline uint32_t
GPIO_readPortData(GPIO_Port port)
{
volatile uint32_t *gpioDataReg;
//
// Get the starting address of the port's registers and return DATA.
//
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((uint32_t)port * GPIO_DATA_REGS_STEP);
return(gpioDataReg[GPIO_GPxDAT_INDEX]);
}
//*****************************************************************************
//
//! Reads the data written in GPIO Data Register.
//!
//! \param port is the GPIO port being accessed in the form of \b GPIO_PORT_X
//! where X is the port letter.
//!
//! Reads the data written in GPIO Data Register for the specified port. In
//! previous devices, read of GPIO data registers resulted in read of
//! corespoinding pins. The function \b GPIO_readPortData() returns the value
//! on pin.
//!
//! \sa GPIO_readPortData()
//!
//! \return Returns the value in the data register for the specified port. Each
//! bit of the the return value represents a pin on the port, where bit 0
//! represents GPIO port pin 0, bit 1 represents GPIO port pin 1, and so on.
//
//*****************************************************************************
static inline uint32_t
GPIO_readPortDataRegister(GPIO_Port port)
{
volatile uint32_t *gpioDataReg;
//
// Get the starting address of the port's registers and return DATA.
//
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATAREAD_BASE) +
((uint32_t)port * GPIO_DATA_READ_REGS_STEP);
return(gpioDataReg[GPIO_GPxDAT_R_INDEX]);
}
//*****************************************************************************
//
//! Writes a value to the specified port.
//!
//! \param port is the GPIO port being accessed.
//! \param outVal is the value to write to the port.
//!
//! This function writes the value \e outVal to the port specified by the
//! \e port parameter which takes a value in the form of \b GPIO_PORT_X where X
//! is the port letter. For example, use \b GPIO_PORT_A to affect port A
//! (GPIOs 0-31).
//!
//! The \e outVal is a bit-packed value, where each bit represents a bit on a
//! GPIO port. Bit 0 represents GPIO port pin 0, bit 1 represents GPIO port
//! pin 1, and so on.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GPIO_writePortData(GPIO_Port port, uint32_t outVal)
{
volatile uint32_t *gpioDataReg;
//
// Get the starting address of the port's registers and write to DATA.
//
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((uint32_t)port * GPIO_DATA_REGS_STEP);
gpioDataReg[GPIO_GPxDAT_INDEX] = outVal;
}
//*****************************************************************************
//
//! Sets all of the specified pins on the specified port.
//!
//! \param port is the GPIO port being accessed.
//! \param pinMask is a mask of which of the 32 pins on the port are affected.
//!
//! This function sets all of the pins specified by the \e pinMask parameter on
//! the port specified by the \e port parameter which takes a value in the
//! form of \b GPIO_PORT_X where X is the port letter. For example, use
//! \b GPIO_PORT_A to affect port A (GPIOs 0-31).
//!
//! The \e pinMask is a bit-packed value, where each bit that is set identifies
//! the pin to be set. Bit 0 represents GPIO port pin 0, bit 1 represents GPIO
//! port pin 1, and so on.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GPIO_setPortPins(GPIO_Port port, uint32_t pinMask)
{
volatile uint32_t *gpioDataReg;
//
// Get the starting address of the port's registers and write to SET.
//
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((uint32_t)port * GPIO_DATA_REGS_STEP);
gpioDataReg[GPIO_GPxSET_INDEX] = pinMask;
}
//*****************************************************************************
//
//! Clears all of the specified pins on the specified port.
//!
//! \param port is the GPIO port being accessed.
//! \param pinMask is a mask of which of the 32 pins on the port are affected.
//!
//! This function clears all of the pins specified by the \e pinMask parameter
//! on the port specified by the \e port parameter which takes a value in the
//! form of \b GPIO_PORT_X where X is the port letter. For example, use
//! \b GPIO_PORT_A to affect port A (GPIOs 0-31).
//!
//! The \e pinMask is a bit-packed value, where each bit that is \b set
//! identifies the pin to be cleared. Bit 0 represents GPIO port pin 0, bit 1
//! represents GPIO port pin 1, and so on.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GPIO_clearPortPins(GPIO_Port port, uint32_t pinMask)
{
volatile uint32_t *gpioDataReg;
//
// Get the starting address of the port's registers and write to CLEAR.
//
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((uint32_t)port * GPIO_DATA_REGS_STEP);
gpioDataReg[GPIO_GPxCLEAR_INDEX] = pinMask;
}
//*****************************************************************************
//
//! Toggles all of the specified pins on the specified port.
//!
//! \param port is the GPIO port being accessed.
//! \param pinMask is a mask of which of the 32 pins on the port are affected.
//!
//! This function toggles all of the pins specified by the \e pinMask parameter
//! on the port specified by the \e port parameter which takes a value in the
//! form of \b GPIO_PORT_X where X is the port letter. For example, use
//! \b GPIO_PORT_A to affect port A (GPIOs 0-31).
//!
//! The \e pinMask is a bit-packed value, where each bit that is set identifies
//! the pin to be toggled. Bit 0 represents GPIO port pin 0, bit 1 represents
//! GPIO port pin 1, and so on.
//!
//! \return None.
//
//*****************************************************************************
static inline void
GPIO_togglePortPins(GPIO_Port port, uint32_t pinMask)
{
volatile uint32_t *gpioDataReg;
//
// Get the starting address of the port's registers and write to TOGGLE.
//
gpioDataReg = (uint32_t *)((uintptr_t)GPIODATA_BASE) +
((uint32_t)port * GPIO_DATA_REGS_STEP);
gpioDataReg[GPIO_GPxTOGGLE_INDEX] = pinMask;
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // GPIO_H
@@ -0,0 +1,207 @@
//###########################################################################
//
// FILE: i2c.c
//
// TITLE: CM I2C driver.
//
//###########################################################################
//
// 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 <stdbool.h>
#include <stdint.h>
#include "inc/hw_i2c.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "debug.h"
#include "i2c.h"
//*****************************************************************************
//
// I2C_initMaster()
//
//*****************************************************************************
void
I2C_initMaster(uint32_t base, uint32_t i2cClk,
bool fast)
{
uint32_t sclFreq;
uint32_t tPr;
//
// Check the arguments.
//
ASSERT(I2C_isBaseValid(base));
//
// Must enable the device before doing anything else.
//
I2C_enableMaster(base);
//
// Get the desired SCL speed.
//
if(fast == true)
{
sclFreq = I2C_SCL_FREQ_FAST_MODE;
}
else
{
sclFreq = I2C_SCL_FREQ_STD_MODE;
}
//
// Compute the clock divider that achieves the fastest speed less than or
// equal to the desired speed. The numerator is biased to favor a larger
// clock divider so that the resulting clock is always less than or equal
// to the desired clock, never greater.
// SCL_PERIOD = 2 X (1 + TPR) X ( SCL_LP + SCL_HP) X CLK_PRD
//
//SCL_PRD is the SCL line period (I2C clock). TPR is the Timer Period
//register value (range of 1 to 127).SCL_LP is the SCL Low period
//(fixed at 6). SCL_HP is the SCL High period (fixed at 4).
//CLK_PRD is the system clock period in ns.
//
tPr = ((i2cClk + (2U * 10U * sclFreq) - 1U) /
(2U * 10U * sclFreq)) - 1U;
HWREG(base + I2C_O_MTPR) = tPr;
//
// Check to see if this I2C peripheral is High-Speed enabled. If yes, also
// choose the fastest speed that is less than or equal to 3.4 Mbps.
// ( SCL_LP + SCL_HP) fixed at 3
//
if((HWREG(base + I2C_O_PP) & I2C_PP_HS) == I2C_PP_HS)
{
tPr = ((i2cClk + (2U * 3U * I2C_SCL_FREQ_HS_MODE) - 1U) /
(2U * 3U * I2C_SCL_FREQ_HS_MODE)) - 1U;
HWREG(base + I2C_O_MTPR) = I2C_MTPR_HS | tPr;
}
}
//*****************************************************************************
//
// I2C_setOwnSlaveAddress()
//
//*****************************************************************************
void
I2C_setOwnSlaveAddress(uint32_t base, I2C_SlaveAddrmode addrNum,
uint8_t slaveAddr)
{
//
// Check the arguments.
//
ASSERT(I2C_isBaseValid(base));
ASSERT(addrNum <= 1U);
ASSERT((slaveAddr & I2C_SA_A6_0_MASK) == 0U);
//
// Determine which slave address is being set.
//
switch((uint8_t)addrNum)
{
//
// Set up the primary slave address.
//
case I2C_SLAVE_ADDR_PRIMARY:
{
HWREG(base + I2C_O_SOAR) = slaveAddr;
break;
}
//
// Set up and enable the secondary slave address.
//
case I2C_SLAVE_ADDR_SECONDARY:
{
HWREG(base + I2C_O_SOAR2) = I2C_SOAR2_OAR2EN | slaveAddr;
break;
}
//
//default case
//
default:
{
break;
}
}
}
//*****************************************************************************
//
// I2C_getMasterErr()
//
//*****************************************************************************
uint32_t
I2C_getMasterErr(uint32_t base)
{
uint32_t err, ret;
//
// Check the arguments.
//
ASSERT(I2C_isBaseValid(base));
//
// Get the raw error state
//
err = HWREG(base + I2C_O_MCS);
//
// If the I2C master is busy, then all the other bit are invalid, and
// don't have an error to report.
//
if((err & I2C_MCS_BUSY) == I2C_MCS_BUSY)
{
ret = I2C_MASTER_ERR_NONE;
}
//
// Check for errors.
//
if((err & (I2C_MCS_ERROR | I2C_MCS_ARBLST))!= 0U)
{
ret = (err & (I2C_MCS_ARBLST | I2C_MCS_DATACK |
I2C_MCS_ADRACK | I2C_MCS_CLKTO));
}
else
{
ret = I2C_MASTER_ERR_NONE;
}
return(ret);
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,177 @@
//###########################################################################
//
// FILE: hw_aes.h
//
// TITLE: Definitions for the AES registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_AES_H
#define HW_AES_H
//*************************************************************************************************
//
// The following are defines for the AES register offsets
//
//*************************************************************************************************
#define AES_O_KEY2_6 0x0U // XTS Second Key or CBC-MAC Third Key
#define AES_O_KEY2_7 0x4U // XTS Second Key or CBC-MAC Third Key
#define AES_O_KEY2_4 0x8U // XTS/CCM Second Key or CBC-MAC Third Key
#define AES_O_KEY2_5 0xCU // XTS Second Key or CBC-MAC Third Key
#define AES_O_KEY2_2 0x10U // XTS/CCM/CBC-MAC Second Key or Hash Key Input
#define AES_O_KEY2_3 0x14U // XTS/CCM/CBC-MAC Second Key or Hash Key Input
#define AES_O_KEY2_0 0x18U // XTS/CCM/CBC-MAC Second Key or Hash Key Input
#define AES_O_KEY2_1 0x1CU // XTS/CCM/CBC-MAC Second Key or Hash Key Input
#define AES_O_KEY1_6 0x20U // Key
#define AES_O_KEY1_7 0x24U // Key
#define AES_O_KEY1_4 0x28U // Key
#define AES_O_KEY1_5 0x2CU // Key
#define AES_O_KEY1_2 0x30U // Key
#define AES_O_KEY1_3 0x34U // Key
#define AES_O_KEY1_0 0x38U // Key
#define AES_O_KEY1_1 0x3CU // Key
#define AES_O_IV_IN_OUT_0 0x40U // Initialization Vector 0
#define AES_O_IV_IN_OUT_1 0x44U // Initialization Vector 1
#define AES_O_IV_IN_OUT_2 0x48U // Initialization Vector 2
#define AES_O_IV_IN_OUT_3 0x4CU // Initialization Vector 3
#define AES_O_CTRL 0x50U // Input/Output Buffer Control and Mode Selection
#define AES_O_C_LENGTH_0 0x54U // Crypto Data Length 0
#define AES_O_C_LENGTH_1 0x58U // Crypto Data Length 1
#define AES_O_AUTH_LENGTH 0x5CU // AAD Data Length
#define AES_O_DATA_IN_OUT_0 0x60U // Data Word 0
#define AES_O_DATA_IN_OUT_1 0x64U // Data Word 1
#define AES_O_DATA_IN_OUT_2 0x68U // Data Word 2
#define AES_O_DATA_IN_OUT_3 0x6CU // Data Word 3
#define AES_O_TAG_OUT_0 0x70U // Hash Result 0
#define AES_O_TAG_OUT_1 0x74U // Hash Result 1
#define AES_O_TAG_OUT_2 0x78U // Hash Result 2
#define AES_O_TAG_OUT_3 0x7CU // Hash Result 3
#define AES_O_REV 0x80U // Module Revision Number
#define AES_O_SYSCONFIG 0x84U // System Configuration
#define AES_O_SYSSTATUS 0x88U // Reset Status
#define AES_O_IRQSTATUS 0x8CU // Interrupt Status
#define AES_O_IRQENABLE 0x90U // Interrupt Enable
#define AES_O_DIRTY_BITS 0x94U // Accessed / Dirty Bits
//*************************************************************************************************
//
// The following are defines for the bit fields in the AES_CTRL register
//
//*************************************************************************************************
#define AES_CTRL_OUTPUT_READY 0x1U // Output Ready Status
#define AES_CTRL_INPUT_READY 0x2U // Input Ready Status
#define AES_CTRL_DIRECTION 0x4U // Encryption/Decryption Selection
#define AES_CTRL_KEY_SIZE_S 3U
#define AES_CTRL_KEY_SIZE_M 0x18U // Key Size
#define AES_CTRL_MODE 0x20U // ECB/CBC Mode
#define AES_CTRL_CTR 0x40U // Counter Mode
#define AES_CTRL_CTR_WIDTH_S 7U
#define AES_CTRL_CTR_WIDTH_M 0x180U // AES-CTR Mode Counter Width
#define AES_CTRL_ICM 0x200U // AES Integer Counter Mode (ICM) Enable
#define AES_CTRL_CFB 0x400U // Full block AES cipher feedback mode (CFB128)
// Enable
#define AES_CTRL_XTS_S 11U
#define AES_CTRL_XTS_M 0x1800U // AES-XTS Operation Enable
#define AES_CTRL_F8 0x2000U // AES f8 Mode Enable
#define AES_CTRL_F9 0x4000U // AES f9 Mode Enable
#define AES_CTRL_CBCMAC 0x8000U // AES-CBC MAC Enable
#define AES_CTRL_GCM_S 16U
#define AES_CTRL_GCM_M 0x30000U // AES-GCM Mode Enable
#define AES_CTRL_CCM 0x40000U // AES-CCM Mode Enable
#define AES_CTRL_CCM_L_S 19U
#define AES_CTRL_CCM_L_M 0x380000U // Width of the length field for CCM operations
#define AES_CTRL_CCM_M_S 22U
#define AES_CTRL_CCM_M_M 0x1C00000U // Length of the authentication field for CCM
// operations
#define AES_CTRL_SAVE_CONTEXT 0x20000000U // TAG or Result IV Save
#define AES_CTRL_SVCTXTRDY 0x40000000U // AES TAG/IV Block(s) Ready
#define AES_CTRL_CTXTRDY 0x80000000U // Context Data Registers Ready
//*************************************************************************************************
//
// The following are defines for the bit fields in the AES_SYSCONFIG register
//
//*************************************************************************************************
#define AES_SYSCONFIG_AUTOIDLE 0x1U // autoidle
#define AES_SYSCONFIG_SOFTRESET 0x2U // Soft Reset
#define AES_SYSCONFIG_SIDLE_S 2U
#define AES_SYSCONFIG_SIDLE_M 0xCU // Slave Idle Mode
#define AES_SYSCONFIG_DMA_REQ_DATA_IN_EN 0x20U // DMA Request Data In Enable
#define AES_SYSCONFIG_DMA_REQ_DATA_OUT_EN 0x40U // DMA Request Data Out Enable
#define AES_SYSCONFIG_DMA_REQ_CONTEXT_IN_EN 0x80U // DMA Request Context In Enable
#define AES_SYSCONFIG_DMA_REQ_CONTEXT_OUT_EN 0x100U // DMA Request Context Out Enable
#define AES_SYSCONFIG_MAP_CONTEXT_OUT_ON_DATA_OUT 0x200U // Map Context Out on Data Out Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the AES_SYSSTATUS register
//
//*************************************************************************************************
#define AES_SYSSTATUS_RESETDONE 0x1U // Reset Done
//*************************************************************************************************
//
// The following are defines for the bit fields in the AES_IRQSTATUS register
//
//*************************************************************************************************
#define AES_IRQSTATUS_CONTEXT_IN 0x1U // Context In Interrupt Status
#define AES_IRQSTATUS_DATA_IN 0x2U // Data In Interrupt Status
#define AES_IRQSTATUS_DATA_OUT 0x4U // Data Out Interrupt Status
#define AES_IRQSTATUS_CONTEXT_OUT 0x8U // Context Output Interrupt Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the AES_IRQENABLE register
//
//*************************************************************************************************
#define AES_IRQENABLE_CONTEXT_IN 0x1U // Context In Interrupt Enable
#define AES_IRQENABLE_DATA_IN 0x2U // Data In Interrupt Enable
#define AES_IRQENABLE_DATA_OUT 0x4U // Data Out Interrupt Enable
#define AES_IRQENABLE_CONTEXT_OUT 0x8U // Context Out Interrupt Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the AES_DIRTY_BITS register
//
//*************************************************************************************************
#define AES_DIRTY_BITS_S_ACCESS 0x1U // AES Access Bit
#define AES_DIRTY_BITS_S_DIRTY 0x2U // AES Dirty Bit
#endif
@@ -0,0 +1,88 @@
//###########################################################################
//
// FILE: hw_aes_ss.h
//
// TITLE: Definitions for the AES_SS registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_AES_SS_H
#define HW_AES_SS_H
//*************************************************************************************************
//
// The following are defines for the AES_SS register offsets
//
//*************************************************************************************************
#define AES_SS_O_AESDMAINTEN 0x0U // DMA Done Interrupt enable register
#define AES_SS_O_AESDMASTATUS 0x4U // DMA Done Interrupt status register
#define AES_SS_O_AESDMASTATUSCLR 0x8U // DMA Done Interrupt status clear register
//*************************************************************************************************
//
// The following are defines for the bit fields in the AESDMAINTEN register
//
//*************************************************************************************************
#define AES_SS_AESDMAINTEN_DMADONECTXIN 0x1U // Enable bit for DMADONECTXIN
#define AES_SS_AESDMAINTEN_DMADONEDIN 0x2U // Enable bit for DMADONEDIN
#define AES_SS_AESDMAINTEN_DMADONEDOUT 0x4U // Enable bit for DMADONEDOUT
#define AES_SS_AESDMAINTEN_DMADONECTXOUT 0x8U // Enable bit for DMADONECTXOUT
//*************************************************************************************************
//
// The following are defines for the bit fields in the AESDMASTATUS register
//
//*************************************************************************************************
#define AES_SS_AESDMASTATUS_DMADONECTXIN 0x1U // Status bit for DMADONECTXIN
#define AES_SS_AESDMASTATUS_DMADONEDIN 0x2U // Status bit for DMADONEDIN
#define AES_SS_AESDMASTATUS_DMADONEDOUT 0x4U // Status bit for DMADONEDOUT
#define AES_SS_AESDMASTATUS_DMADONECTXOUT 0x8U // Status bit for DMADONECTXOUT
//*************************************************************************************************
//
// The following are defines for the bit fields in the AESDMASTATUSCLR register
//
//*************************************************************************************************
#define AES_SS_AESDMASTATUSCLR_DMADONECTXIN 0x1U // Clear bit for AESDMASTSTAUS.DMADONECTXIN
#define AES_SS_AESDMASTATUSCLR_DMADONEDIN 0x2U // Clear bit for AESDMASTSTAUS.DMADONEDIN
#define AES_SS_AESDMASTATUSCLR_DMADONEDOUT 0x4U // Clear bit for AESDMASTSTAUS.DMADONEDOUT
#define AES_SS_AESDMASTATUSCLR_DMADONECTXOUT 0x8U // Clear bit for AESDMASTSTAUS.DMADONECTXOUT
#endif
@@ -0,0 +1,519 @@
//###########################################################################
//
// FILE: hw_can.h
//
// TITLE: Definitions for the CAN registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_CAN_H
#define HW_CAN_H
//*************************************************************************************************
//
// The following are defines for the CAN register offsets
//
//*************************************************************************************************
#define CAN_O_CTL 0x0U // CAN Control Register
#define CAN_O_ES 0x4U // Error and Status Register
#define CAN_O_ERRC 0x8U // Error Counter Register
#define CAN_O_BTR 0xCU // Bit Timing Register
#define CAN_O_INT 0x10U // Interrupt Register
#define CAN_O_TEST 0x14U // Test Register
#define CAN_O_PERR 0x1CU // CAN Parity Error Code Register
#define CAN_O_RAM_INIT 0x40U // CAN RAM Initialization Register
#define CAN_O_GLB_INT_EN 0x50U // CAN Global Interrupt Enable Register
#define CAN_O_GLB_INT_FLG 0x54U // CAN Global Interrupt Flag Register
#define CAN_O_GLB_INT_CLR 0x58U // CAN Global Interrupt Clear Register
#define CAN_O_ABOTR 0x80U // Auto-Bus-On Time Register
#define CAN_O_TXRQ_X 0x84U // CAN Transmission Request Register
#define CAN_O_TXRQ_21 0x88U // CAN Transmission Request 2_1 Register
#define CAN_O_NDAT_X 0x98U // CAN New Data Register
#define CAN_O_NDAT_21 0x9CU // CAN New Data 2_1 Register
#define CAN_O_IPEN_X 0xACU // CAN Interrupt Pending Register
#define CAN_O_IPEN_21 0xB0U // CAN Interrupt Pending 2_1 Register
#define CAN_O_MVAL_X 0xC0U // CAN Message Valid Register
#define CAN_O_MVAL_21 0xC4U // CAN Message Valid 2_1 Register
#define CAN_O_IP_MUX21 0xD8U // CAN Interrupt Multiplexer 2_1 Register
#define CAN_O_IF1CMD 0x100U // IF1 Command Register
#define CAN_O_IF1MSK 0x104U // IF1 Mask Register
#define CAN_O_IF1ARB 0x108U // IF1 Arbitration Register
#define CAN_O_IF1MCTL 0x10CU // IF1 Message Control Register
#define CAN_O_IF1DATA 0x110U // IF1 Data A Register
#define CAN_O_IF1DATB 0x114U // IF1 Data B Register
#define CAN_O_IF2CMD 0x120U // IF2 Command Register
#define CAN_O_IF2MSK 0x124U // IF2 Mask Register
#define CAN_O_IF2ARB 0x128U // IF2 Arbitration Register
#define CAN_O_IF2MCTL 0x12CU // IF2 Message Control Register
#define CAN_O_IF2DATA 0x130U // IF2 Data A Register
#define CAN_O_IF2DATB 0x134U // IF2 Data B Register
#define CAN_O_IF3OBS 0x140U // IF3 Observation Register
#define CAN_O_IF3MSK 0x144U // IF3 Mask Register
#define CAN_O_IF3ARB 0x148U // IF3 Arbitration Register
#define CAN_O_IF3MCTL 0x14CU // IF3 Message Control Register
#define CAN_O_IF3DATA 0x150U // IF3 Data A Register
#define CAN_O_IF3DATB 0x154U // IF3 Data B Register
#define CAN_O_IF3UPD 0x160U // IF3 Update Enable Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_CTL register
//
//*************************************************************************************************
#define CAN_CTL_INIT 0x1U // Initialization
#define CAN_CTL_IE0 0x2U // Interrupt line 0 Enable
#define CAN_CTL_SIE 0x4U // Status Change Interrupt Enable
#define CAN_CTL_EIE 0x8U // Error Interrupt Enable
#define CAN_CTL_DAR 0x20U // Disable Automatic Retransmission
#define CAN_CTL_CCE 0x40U // Configuration Change Enable
#define CAN_CTL_TEST 0x80U // Test Mode Enable
#define CAN_CTL_IDS 0x100U // Interruption Debug Support Enable
#define CAN_CTL_ABO 0x200U // Auto-Bus-On Enable
#define CAN_CTL_PMD_S 10U
#define CAN_CTL_PMD_M 0x3C00U // Parity on/off
#define CAN_CTL_SWR 0x8000U // SW Reset Enable
#define CAN_CTL_INITDBG 0x10000U // Debug Mode Status
#define CAN_CTL_IE1 0x20000U // Interrupt line 1 Enable Disabled
#define CAN_CTL_DE1 0x40000U // Enable DMA request line
#define CAN_CTL_DE2 0x80000U // Enable DMA request line
#define CAN_CTL_DE3 0x100000U // Enable DMA request line
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_ES register
//
//*************************************************************************************************
#define CAN_ES_LEC_S 0U
#define CAN_ES_LEC_M 0x7U // Last Error Code
#define CAN_ES_TXOK 0x8U // Transmission status
#define CAN_ES_RXOK 0x10U // Reception status
#define CAN_ES_EPASS 0x20U // Error Passive State
#define CAN_ES_EWARN 0x40U // Warning State
#define CAN_ES_BOFF 0x80U // Bus-Off State
#define CAN_ES_PER 0x100U // Parity Error Detected
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_ERRC register
//
//*************************************************************************************************
#define CAN_ERRC_TEC_S 0U
#define CAN_ERRC_TEC_M 0xFFU // Transmit Error Counter
#define CAN_ERRC_REC_S 8U
#define CAN_ERRC_REC_M 0x7F00U // Receive Error Counter
#define CAN_ERRC_RP 0x8000U // Receive Error Passive
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_BTR register
//
//*************************************************************************************************
#define CAN_BTR_BRP_S 0U
#define CAN_BTR_BRP_M 0x3FU // Baud Rate Prescaler
#define CAN_BTR_SJW_S 6U
#define CAN_BTR_SJW_M 0xC0U // Synchronization Jump Width
#define CAN_BTR_TSEG1_S 8U
#define CAN_BTR_TSEG1_M 0xF00U // Time segment
#define CAN_BTR_TSEG2_S 12U
#define CAN_BTR_TSEG2_M 0x7000U // Time segment
#define CAN_BTR_BRPE_S 16U
#define CAN_BTR_BRPE_M 0xF0000U // Baud Rate Prescaler Extension
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_INT register
//
//*************************************************************************************************
#define CAN_INT_INT0ID_S 0U
#define CAN_INT_INT0ID_M 0xFFFFU // Interrupt Identifier
#define CAN_INT_INT1ID_S 16U
#define CAN_INT_INT1ID_M 0xFF0000U // Interrupt 1 Identifier
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_TEST register
//
//*************************************************************************************************
#define CAN_TEST_SILENT 0x8U // Silent Mode
#define CAN_TEST_LBACK 0x10U // Loopback Mode
#define CAN_TEST_TX_S 5U
#define CAN_TEST_TX_M 0x60U // CANTX Pin Control
#define CAN_TEST_RX 0x80U // CANRX Pin Status
#define CAN_TEST_EXL 0x100U // External Loopback Mode
#define CAN_TEST_RDA 0x200U // RAM Direct Access Enable:
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_PERR register
//
//*************************************************************************************************
#define CAN_PERR_MSG_NUM_S 0U
#define CAN_PERR_MSG_NUM_M 0xFFU // Message Number
#define CAN_PERR_WORD_NUM_S 8U
#define CAN_PERR_WORD_NUM_M 0x700U // Word Number
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_RAM_INIT register
//
//*************************************************************************************************
#define CAN_RAM_INIT_KEY0 0x1U // KEY0
#define CAN_RAM_INIT_KEY1 0x2U // KEY1
#define CAN_RAM_INIT_KEY2 0x4U // KEY2
#define CAN_RAM_INIT_KEY3 0x8U // KEY3
#define CAN_RAM_INIT_CAN_RAM_INIT 0x10U // Initialize CAN Mailbox RAM
#define CAN_RAM_INIT_RAM_INIT_DONE 0x20U // CAN RAM initialization complete
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_GLB_INT_EN register
//
//*************************************************************************************************
#define CAN_GLB_INT_EN_GLBINT0_EN 0x1U // Global Interrupt Enable for CANINT0
#define CAN_GLB_INT_EN_GLBINT1_EN 0x2U // Global Interrupt Enable for CANINT1
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_GLB_INT_FLG register
//
//*************************************************************************************************
#define CAN_GLB_INT_FLG_INT0_FLG 0x1U // Global Interrupt Flag for CANINT0
#define CAN_GLB_INT_FLG_INT1_FLG 0x2U // Global Interrupt Flag for CANINT1
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_GLB_INT_CLR register
//
//*************************************************************************************************
#define CAN_GLB_INT_CLR_INT0_FLG_CLR 0x1U // Global Interrupt flag clear for CANINT0
#define CAN_GLB_INT_CLR_INT1_FLG_CLR 0x2U // Global Interrupt flag clear for CANINT1
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_TXRQ_X register
//
//*************************************************************************************************
#define CAN_TXRQ_X_TXRQSTREG1_S 0U
#define CAN_TXRQ_X_TXRQSTREG1_M 0x3U // Transmit Request Register 1
#define CAN_TXRQ_X_TXRQSTREG2_S 2U
#define CAN_TXRQ_X_TXRQSTREG2_M 0xCU // Transmit Request Register 2
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_NDAT_X register
//
//*************************************************************************************************
#define CAN_NDAT_X_NEWDATREG1_S 0U
#define CAN_NDAT_X_NEWDATREG1_M 0x3U // New Data Register 1
#define CAN_NDAT_X_NEWDATREG2_S 2U
#define CAN_NDAT_X_NEWDATREG2_M 0xCU // New Data Register 2
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IPEN_X register
//
//*************************************************************************************************
#define CAN_IPEN_X_INTPNDREG1_S 0U
#define CAN_IPEN_X_INTPNDREG1_M 0x3U // Interrupt Pending Register 1
#define CAN_IPEN_X_INTPNDREG2_S 2U
#define CAN_IPEN_X_INTPNDREG2_M 0xCU // Interrupt Pending Register 2
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_MVAL_X register
//
//*************************************************************************************************
#define CAN_MVAL_X_MSGVALREG1_S 0U
#define CAN_MVAL_X_MSGVALREG1_M 0x3U // Message Valid Register 1
#define CAN_MVAL_X_MSGVALREG2_S 2U
#define CAN_MVAL_X_MSGVALREG2_M 0xCU // Message Valid Register 2
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF1CMD register
//
//*************************************************************************************************
#define CAN_IF1CMD_MSG_NUM_S 0U
#define CAN_IF1CMD_MSG_NUM_M 0xFFU // Message Number
#define CAN_IF1CMD_DMAACTIVE 0x4000U // DMA Status
#define CAN_IF1CMD_BUSY 0x8000U // Busy Flag
#define CAN_IF1CMD_DATA_B 0x10000U // Access Data Bytes 4-7
#define CAN_IF1CMD_DATA_A 0x20000U // Access Data Bytes 0-3
#define CAN_IF1CMD_TXRQST 0x40000U // Access Transmission Request Bit
#define CAN_IF1CMD_CLRINTPND 0x80000U // Clear Interrupt Pending Bit
#define CAN_IF1CMD_CONTROL 0x100000U // Access Control Bits
#define CAN_IF1CMD_ARB 0x200000U // Access Arbitration Bits
#define CAN_IF1CMD_MASK 0x400000U // Access Mask Bits
#define CAN_IF1CMD_DIR 0x800000U // Write/Read Direction
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF1MSK register
//
//*************************************************************************************************
#define CAN_IF1MSK_MSK_S 0U
#define CAN_IF1MSK_MSK_M 0x1FFFFFFFU // Identifier Mask
#define CAN_IF1MSK_MDIR 0x40000000U // Mask Message Direction
#define CAN_IF1MSK_MXTD 0x80000000U // Mask Extended Identifier
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF1ARB register
//
//*************************************************************************************************
#define CAN_IF1ARB_ID_S 0U
#define CAN_IF1ARB_ID_M 0x1FFFFFFFU // `
#define CAN_IF1ARB_DIR 0x20000000U // Message Direction
#define CAN_IF1ARB_XTD 0x40000000U // Extended Identifier
#define CAN_IF1ARB_MSGVAL 0x80000000U // Message Valid
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF1MCTL register
//
//*************************************************************************************************
#define CAN_IF1MCTL_DLC_S 0U
#define CAN_IF1MCTL_DLC_M 0xFU // Data length code
#define CAN_IF1MCTL_EOB 0x80U // End of Block
#define CAN_IF1MCTL_TXRQST 0x100U // Transmit Request
#define CAN_IF1MCTL_RMTEN 0x200U // Remote Enable
#define CAN_IF1MCTL_RXIE 0x400U // Receive Interrupt Enable
#define CAN_IF1MCTL_TXIE 0x800U // Transmit Interrupt Enable
#define CAN_IF1MCTL_UMASK 0x1000U // Use Acceptance Mask
#define CAN_IF1MCTL_INTPND 0x2000U // Interrupt Pending
#define CAN_IF1MCTL_MSGLST 0x4000U // Message Lost
#define CAN_IF1MCTL_NEWDAT 0x8000U // New Data
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF1DATA register
//
//*************************************************************************************************
#define CAN_IF1DATA_DATA_0_S 0U
#define CAN_IF1DATA_DATA_0_M 0xFFU // Data Byte 0
#define CAN_IF1DATA_DATA_1_S 8U
#define CAN_IF1DATA_DATA_1_M 0xFF00U // Data Byte 1
#define CAN_IF1DATA_DATA_2_S 16U
#define CAN_IF1DATA_DATA_2_M 0xFF0000U // Data Byte 2
#define CAN_IF1DATA_DATA_3_S 24U
#define CAN_IF1DATA_DATA_3_M 0xFF000000U // Data Byte 3
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF1DATB register
//
//*************************************************************************************************
#define CAN_IF1DATB_DATA_4_S 0U
#define CAN_IF1DATB_DATA_4_M 0xFFU // Data Byte 4
#define CAN_IF1DATB_DATA_5_S 8U
#define CAN_IF1DATB_DATA_5_M 0xFF00U // Data Byte 5
#define CAN_IF1DATB_DATA_6_S 16U
#define CAN_IF1DATB_DATA_6_M 0xFF0000U // Data Byte 6
#define CAN_IF1DATB_DATA_7_S 24U
#define CAN_IF1DATB_DATA_7_M 0xFF000000U // Data Byte 7
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF2CMD register
//
//*************************************************************************************************
#define CAN_IF2CMD_MSG_NUM_S 0U
#define CAN_IF2CMD_MSG_NUM_M 0xFFU // Message Number
#define CAN_IF2CMD_DMAACTIVE 0x4000U // DMA Status
#define CAN_IF2CMD_BUSY 0x8000U // Busy Flag
#define CAN_IF2CMD_DATA_B 0x10000U // Access Data Bytes 4-7
#define CAN_IF2CMD_DATA_A 0x20000U // Access Data Bytes 0-3
#define CAN_IF2CMD_TXRQST 0x40000U // Access Transmission Request Bit
#define CAN_IF2CMD_CLRINTPND 0x80000U // Clear Interrupt Pending Bit
#define CAN_IF2CMD_CONTROL 0x100000U // Access Control Bits
#define CAN_IF2CMD_ARB 0x200000U // Access Arbitration Bits
#define CAN_IF2CMD_MASK 0x400000U // Access Mask Bits
#define CAN_IF2CMD_DIR 0x800000U // Write/Read Direction
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF2MSK register
//
//*************************************************************************************************
#define CAN_IF2MSK_MSK_S 0U
#define CAN_IF2MSK_MSK_M 0x1FFFFFFFU // Identifier Mask
#define CAN_IF2MSK_MDIR 0x40000000U // Mask Message Direction
#define CAN_IF2MSK_MXTD 0x80000000U // Mask Extended Identifier
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF2ARB register
//
//*************************************************************************************************
#define CAN_IF2ARB_ID_S 0U
#define CAN_IF2ARB_ID_M 0x1FFFFFFFU // Message Identifier
#define CAN_IF2ARB_DIR 0x20000000U // Message Direction
#define CAN_IF2ARB_XTD 0x40000000U // Extended Identifier
#define CAN_IF2ARB_MSGVAL 0x80000000U // Message Valid
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF2MCTL register
//
//*************************************************************************************************
#define CAN_IF2MCTL_DLC_S 0U
#define CAN_IF2MCTL_DLC_M 0xFU // Data length code
#define CAN_IF2MCTL_EOB 0x80U // End of Block
#define CAN_IF2MCTL_TXRQST 0x100U // Transmit Request
#define CAN_IF2MCTL_RMTEN 0x200U // Remote Enable
#define CAN_IF2MCTL_RXIE 0x400U // Receive Interrupt Enable
#define CAN_IF2MCTL_TXIE 0x800U // Transmit Interrupt Enable
#define CAN_IF2MCTL_UMASK 0x1000U // Use Acceptance Mask
#define CAN_IF2MCTL_INTPND 0x2000U // Interrupt Pending
#define CAN_IF2MCTL_MSGLST 0x4000U // Message Lost
#define CAN_IF2MCTL_NEWDAT 0x8000U // New Data
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF2DATA register
//
//*************************************************************************************************
#define CAN_IF2DATA_DATA_0_S 0U
#define CAN_IF2DATA_DATA_0_M 0xFFU // Data Byte 0
#define CAN_IF2DATA_DATA_1_S 8U
#define CAN_IF2DATA_DATA_1_M 0xFF00U // Data Byte 1
#define CAN_IF2DATA_DATA_2_S 16U
#define CAN_IF2DATA_DATA_2_M 0xFF0000U // Data Byte 2
#define CAN_IF2DATA_DATA_3_S 24U
#define CAN_IF2DATA_DATA_3_M 0xFF000000U // Data Byte 3
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF2DATB register
//
//*************************************************************************************************
#define CAN_IF2DATB_DATA_4_S 0U
#define CAN_IF2DATB_DATA_4_M 0xFFU // Data Byte 4
#define CAN_IF2DATB_DATA_5_S 8U
#define CAN_IF2DATB_DATA_5_M 0xFF00U // Data Byte 5
#define CAN_IF2DATB_DATA_6_S 16U
#define CAN_IF2DATB_DATA_6_M 0xFF0000U // Data Byte 6
#define CAN_IF2DATB_DATA_7_S 24U
#define CAN_IF2DATB_DATA_7_M 0xFF000000U // Data Byte 7
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF3OBS register
//
//*************************************************************************************************
#define CAN_IF3OBS_MASK 0x1U // Mask data read observation
#define CAN_IF3OBS_ARB 0x2U // Arbitration data read observation
#define CAN_IF3OBS_CTRL 0x4U // Ctrl read observation
#define CAN_IF3OBS_DATA_A 0x8U // Data A read observation
#define CAN_IF3OBS_DATA_B 0x10U // Data B read observation
#define CAN_IF3OBS_IF3SM 0x100U // IF3 Status of Mask data read access
#define CAN_IF3OBS_IF3SA 0x200U // IF3 Status of Arbitration data read access
#define CAN_IF3OBS_IF3SC 0x400U // IF3 Status of Control bits read access
#define CAN_IF3OBS_IF3SDA 0x800U // IF3 Status of Data A read access
#define CAN_IF3OBS_IF3SDB 0x1000U // IF3 Status of Data B read access
#define CAN_IF3OBS_IF3UPD 0x8000U // IF3 Update Data
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF3MSK register
//
//*************************************************************************************************
#define CAN_IF3MSK_MSK_S 0U
#define CAN_IF3MSK_MSK_M 0x1FFFFFFFU // Mask
#define CAN_IF3MSK_MDIR 0x40000000U // Mask Message Direction
#define CAN_IF3MSK_MXTD 0x80000000U // Mask Extended Identifier
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF3ARB register
//
//*************************************************************************************************
#define CAN_IF3ARB_ID_S 0U
#define CAN_IF3ARB_ID_M 0x1FFFFFFFU // Message Identifier
#define CAN_IF3ARB_DIR 0x20000000U // Message Direction
#define CAN_IF3ARB_XTD 0x40000000U // Extended Identifier
#define CAN_IF3ARB_MSGVAL 0x80000000U // Message Valid
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF3MCTL register
//
//*************************************************************************************************
#define CAN_IF3MCTL_DLC_S 0U
#define CAN_IF3MCTL_DLC_M 0xFU // Data length code
#define CAN_IF3MCTL_EOB 0x80U // End of Block
#define CAN_IF3MCTL_TXRQST 0x100U // Transmit Request
#define CAN_IF3MCTL_RMTEN 0x200U // Remote Enable
#define CAN_IF3MCTL_RXIE 0x400U // Receive Interrupt Enable
#define CAN_IF3MCTL_TXIE 0x800U // Transmit Interrupt Enable
#define CAN_IF3MCTL_UMASK 0x1000U // Use Acceptance Mask
#define CAN_IF3MCTL_INTPND 0x2000U // Interrupt Pending
#define CAN_IF3MCTL_MSGLST 0x4000U // Message Lost
#define CAN_IF3MCTL_NEWDAT 0x8000U // New Data
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF3DATA register
//
//*************************************************************************************************
#define CAN_IF3DATA_DATA_0_S 0U
#define CAN_IF3DATA_DATA_0_M 0xFFU // Data Byte 0
#define CAN_IF3DATA_DATA_1_S 8U
#define CAN_IF3DATA_DATA_1_M 0xFF00U // Data Byte 1
#define CAN_IF3DATA_DATA_2_S 16U
#define CAN_IF3DATA_DATA_2_M 0xFF0000U // Data Byte 2
#define CAN_IF3DATA_DATA_3_S 24U
#define CAN_IF3DATA_DATA_3_M 0xFF000000U // Data Byte 3
//*************************************************************************************************
//
// The following are defines for the bit fields in the CAN_IF3DATB register
//
//*************************************************************************************************
#define CAN_IF3DATB_DATA_4_S 0U
#define CAN_IF3DATB_DATA_4_M 0xFFU // Data Byte 4
#define CAN_IF3DATB_DATA_5_S 8U
#define CAN_IF3DATB_DATA_5_M 0xFF00U // Data Byte 5
#define CAN_IF3DATB_DATA_6_S 16U
#define CAN_IF3DATB_DATA_6_M 0xFF0000U // Data Byte 6
#define CAN_IF3DATB_DATA_7_S 24U
#define CAN_IF3DATB_DATA_7_M 0xFF000000U // Data Byte 7
#endif
@@ -0,0 +1,281 @@
//###########################################################################
//
// FILE: hw_cmmpu.h
//
// TITLE: Definitions for the CMMPU registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_CMMPU_H
#define HW_CMMPU_H
//*************************************************************************************************
//
// The following are defines for the CMMPU register offsets
//
//*************************************************************************************************
#define CMMPU_O_MPU_CONTROL_REG 0x0U // MPU control regster
#define CMMPU_O_ACC_VIO_INTEN 0x20U // Access violation interrupt enable
#define CMMPU_O_ACC_VIO_FLAGS 0x24U // Access violation flag register
#define CMMPU_O_ACC_VIO_FLAGS_SET 0x28U // Acesss violation set register
#define CMMPU_O_ACC_VIO_FLAGS_CLR 0x2CU // Access violation clear register
#define CMMPU_O_ACC_VIO_ADDR_REG 0x30U // Access violation address register
#define CMMPU_O_REGION0_STARTADDRESSS 0x40U // Region 0 start address register
#define CMMPU_O_REGION0_CONFIG 0x44U // Region 0 configuration register
#define CMMPU_O_REGION1_STARTADDRESSS 0x48U // Region 1 start address register
#define CMMPU_O_REGION1_CONFIG 0x4CU // Region 1 configuration register
#define CMMPU_O_REGION2_STARTADDRESSS 0x50U // Region 2 start address register
#define CMMPU_O_REGION2_CONFIG 0x54U // Region 2 configuration register
#define CMMPU_O_REGION3_STARTADDRESSS 0x58U // Region 3 start address register
#define CMMPU_O_REGION3_CONFIG 0x5CU // Region 3 configuration register
#define CMMPU_O_REGION4_STARTADDRESSS 0x60U // Region 4 start address register
#define CMMPU_O_REGION4_CONFIG 0x64U // Region 4 configuration register
#define CMMPU_O_REGION5_STARTADDRESSS 0x68U // Region 5 start address register
#define CMMPU_O_REGION5_CONFIG 0x6CU // Region 5 configuration register
#define CMMPU_O_REGION6_STARTADDRESSS 0x70U // Region 6 start address register
#define CMMPU_O_REGION6_CONFIG 0x74U // Region 6 configuration register
#define CMMPU_O_REGION7_STARTADDRESSS 0x78U // Region 7 start address register
#define CMMPU_O_REGION7_CONFIG 0x7CU // Region 7 configuration register
//*************************************************************************************************
//
// The following are defines for the bit fields in the MPU_CONTROL_REG register
//
//*************************************************************************************************
#define CMMPU_MPU_CONTROL_REG_ENABLE 0x1U // Global Enable register
//*************************************************************************************************
//
// The following are defines for the bit fields in the ACC_VIO_INTEN register
//
//*************************************************************************************************
#define CMMPU_ACC_VIO_INTEN_INTEN 0x1U // Interrupt enable register
#define CMMPU_ACC_VIO_INTEN_KEY_S 16U
#define CMMPU_ACC_VIO_INTEN_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the ACC_VIO_FLAGS register
//
//*************************************************************************************************
#define CMMPU_ACC_VIO_FLAGS_RD 0x1U // Read access violation flag
#define CMMPU_ACC_VIO_FLAGS_WR 0x2U // Write access violation flag
//*************************************************************************************************
//
// The following are defines for the bit fields in the ACC_VIO_FLAGS_SET register
//
//*************************************************************************************************
#define CMMPU_ACC_VIO_FLAGS_SET_RD 0x1U // Read access violation flag set
#define CMMPU_ACC_VIO_FLAGS_SET_WR 0x2U // Write access violation flag set
#define CMMPU_ACC_VIO_FLAGS_SET_KEY_S 16U
#define CMMPU_ACC_VIO_FLAGS_SET_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the ACC_VIO_FLAGS_CLR register
//
//*************************************************************************************************
#define CMMPU_ACC_VIO_FLAGS_CLR_RD 0x1U // Read access violation flag clear
#define CMMPU_ACC_VIO_FLAGS_CLR_WR 0x2U // Write access violation flag clear
#define CMMPU_ACC_VIO_FLAGS_CLR_KEY_S 16U
#define CMMPU_ACC_VIO_FLAGS_CLR_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION0_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION0_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION0_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION0_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION0_CONFIG_SIZE_S 8U
#define CMMPU_REGION0_CONFIG_SIZE_M 0x1F00U // Size of the region 0
#define CMMPU_REGION0_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION0_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION0_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION0_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION0_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION0_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION0_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION0_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION1_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION1_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION1_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION1_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION1_CONFIG_SIZE_S 8U
#define CMMPU_REGION1_CONFIG_SIZE_M 0x1F00U // Size of the region 1
#define CMMPU_REGION1_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION1_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION1_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION1_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION1_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION1_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION1_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION1_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION2_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION2_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION2_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION2_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION2_CONFIG_SIZE_S 8U
#define CMMPU_REGION2_CONFIG_SIZE_M 0x1F00U // Size of the region 2
#define CMMPU_REGION2_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION2_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION2_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION2_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION2_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION2_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION2_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION2_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION3_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION3_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION3_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION3_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION3_CONFIG_SIZE_S 8U
#define CMMPU_REGION3_CONFIG_SIZE_M 0x1F00U // Size of the region 3
#define CMMPU_REGION3_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION3_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION3_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION3_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION3_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION3_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION3_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION3_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION4_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION4_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION4_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION4_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION4_CONFIG_SIZE_S 8U
#define CMMPU_REGION4_CONFIG_SIZE_M 0x1F00U // Size of the region 4
#define CMMPU_REGION4_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION4_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION4_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION4_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION4_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION4_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION4_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION4_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION5_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION5_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION5_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION5_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION5_CONFIG_SIZE_S 8U
#define CMMPU_REGION5_CONFIG_SIZE_M 0x1F00U // Size of the region 5
#define CMMPU_REGION5_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION5_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION5_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION5_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION5_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION5_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION5_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION5_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION6_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION6_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION6_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION6_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION6_CONFIG_SIZE_S 8U
#define CMMPU_REGION6_CONFIG_SIZE_M 0x1F00U // Size of the region 6
#define CMMPU_REGION6_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION6_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION6_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION6_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION6_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION6_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION6_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION6_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the REGION7_CONFIG register
//
//*************************************************************************************************
#define CMMPU_REGION7_CONFIG_ENABLE 0x1U // Region Enable bit
#define CMMPU_REGION7_CONFIG_PROT_TYPE_S 4U
#define CMMPU_REGION7_CONFIG_PROT_TYPE_M 0x30U // Access permission configuration
// bits
#define CMMPU_REGION7_CONFIG_SIZE_S 8U
#define CMMPU_REGION7_CONFIG_SIZE_M 0x1F00U // Size of the region 7
#define CMMPU_REGION7_CONFIG_SUBREGION0_DISABLE 0x10000U // Sub region 0 disable bit
#define CMMPU_REGION7_CONFIG_SUBREGION1_DISABLE 0x20000U // Sub region 1 disable bit
#define CMMPU_REGION7_CONFIG_SUBREGION2_DISABLE 0x40000U // Sub region 2 disable bit
#define CMMPU_REGION7_CONFIG_SUBREGION3_DISABLE 0x80000U // Sub region 3 disable bit
#define CMMPU_REGION7_CONFIG_SUBREGION4_DISABLE 0x100000U // Sub region 4 disable bit
#define CMMPU_REGION7_CONFIG_SUBREGION5_DISABLE 0x200000U // Sub region 5 disable bit
#define CMMPU_REGION7_CONFIG_SUBREGION6_DISABLE 0x400000U // Sub region 6 disable bit
#define CMMPU_REGION7_CONFIG_SUBREGION7_DISABLE 0x800000U // Sub region 7 disable bit
#endif
@@ -0,0 +1,85 @@
//###########################################################################
//
// FILE: hw_cputimer.h
//
// TITLE: Definitions for the CPUTIMER registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_CPUTIMER_H
#define HW_CPUTIMER_H
//*************************************************************************************************
//
// The following are defines for the CPUTIMER register offsets
//
//*************************************************************************************************
#define CPUTIMER_O_TIM 0x0U // Timer counter register
#define CPUTIMER_O_PRD 0x4U // Timer period register
#define CPUTIMER_O_TCR 0x8U // Timer control register
#define CPUTIMER_O_TPR 0xCU // Timer prescaler register
//*************************************************************************************************
//
// The following are defines for the bit fields in the TCR register
//
//*************************************************************************************************
#define CPUTIMER_TCR_TSS 0x10U // Timer Stop Status
#define CPUTIMER_TCR_TRB 0x20U // Timer Reload Bit
#define CPUTIMER_TCR_SOFT 0x400U // SOFT stop enable
#define CPUTIMER_TCR_FREE 0x800U // Free run enable
#define CPUTIMER_TCR_TIE 0x4000U // Timer Interrupt Enable
#define CPUTIMER_TCR_TIF 0x8000U // Timer Intrerrupt Flag
//*************************************************************************************************
//
// The following are defines for the bit fields in the TPR register
//
//*************************************************************************************************
#define CPUTIMER_TPR_TDDRL_S 0U
#define CPUTIMER_TPR_TDDRL_M 0xFFU // Timer Divide Down Register Low
#define CPUTIMER_TPR_PSCL_S 8U
#define CPUTIMER_TPR_PSCL_M 0xFF00U // Prescaler Counter low
#define CPUTIMER_TPR_TDDRH_S 16U
#define CPUTIMER_TPR_TDDRH_M 0xFF0000U // Timer Divide Down Register High
#define CPUTIMER_TPR_PSCH_S 24U
#define CPUTIMER_TPR_PSCH_M 0xFF000000U // Prescaler Counter high
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,149 @@
//###########################################################################
//
// FILE: hw_emac_ss.h
//
// TITLE: Definitions for the ETHERNETSS registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_EMAC_SS_H
#define HW_EMAC_SS_H
//*************************************************************************************************
//
// The following are defines for the ETHERNETSS register offsets
//
//*************************************************************************************************
#define ETHERNETSS_O_IPREVNUM 0x0U // IP Revision Number
#define ETHERNETSS_O_CTRLSTS 0x4U // Control Register
#define ETHERNETSS_O_PTPTSTRIGSEL0 0x8U // PTP Trigger-0 select
#define ETHERNETSS_O_PTPTSTRIGSEL1 0xCU // PTP Trigger-1 select
#define ETHERNETSS_O_PTPTSSWTRIG0 0x10U // PTP SW Trigger-0
#define ETHERNETSS_O_PTPTSSWTRIG1 0x14U // PTP SW Trigger-1
#define ETHERNETSS_O_PTPPPSR0 0x18U // PTP PPS-0 Read
#define ETHERNETSS_O_PTPPPSR1 0x1CU // PTP PPS-1 Read
#define ETHERNETSS_O_PTP_TSRL 0x20U // PTP timestamp read lower 32 bits
#define ETHERNETSS_O_PTP_TSRH 0x24U // PTP timestamp read upper 32 bits
#define ETHERNETSS_O_PTP_TSWL 0x28U // External Timestamp write lower 32 bits
#define ETHERNETSS_O_PTP_TSWH 0x2CU // External Timestamp write upper 32 bits
#define ETHERNETSS_O_REVMII_CTRL 0x30U // RevMII Phy Address controls
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_IPREVNUM register
//
//*************************************************************************************************
#define ETHERNETSS_IPREVNUM_IP_REV_MINOR_S 0U
#define ETHERNETSS_IPREVNUM_IP_REV_MINOR_M 0xFU // Minor IP Revision Number
#define ETHERNETSS_IPREVNUM_IP_REV_MAJOR_S 4U
#define ETHERNETSS_IPREVNUM_IP_REV_MAJOR_M 0xF0U // Major IP Revision Number
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_CTRLSTS register
//
//*************************************************************************************************
#define ETHERNETSS_CTRLSTS_PHY_INTF_SEL_S 0U
#define ETHERNETSS_CTRLSTS_PHY_INTF_SEL_M 0x7U // PHY Type Selection
#define ETHERNETSS_CTRLSTS_CLK_LM 0x10U // MII Loop-back mode clock select
#define ETHERNETSS_CTRLSTS_CLK_SRC_SEL 0x80U // Internal Clock Selection
#define ETHERNETSS_CTRLSTS_FLOW_CTRL_EN_S 8U
#define ETHERNETSS_CTRLSTS_FLOW_CTRL_EN_M 0x300U // Back-pressure enable per receive queue.
#define ETHERNETSS_CTRLSTS_WRITE_KEY_S 16U
#define ETHERNETSS_CTRLSTS_WRITE_KEY_M 0xFF0000U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_PTPTSTRIGSEL0 register
//
//*************************************************************************************************
#define ETHERNETSS_PTPTSTRIGSEL0_PTP_AUX_TS_TRIG_SEL0_S 0U
#define ETHERNETSS_PTPTSTRIGSEL0_PTP_AUX_TS_TRIG_SEL0_M 0x1FU // Trigger select for
// Auxillary TS capture - 0
#define ETHERNETSS_PTPTSTRIGSEL0_WRITE_KEY_S 16U
#define ETHERNETSS_PTPTSTRIGSEL0_WRITE_KEY_M 0xFF0000U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_PTPTSTRIGSEL1 register
//
//*************************************************************************************************
#define ETHERNETSS_PTPTSTRIGSEL1_PTP_AUX_TS_TRIG_SEL1_S 0U
#define ETHERNETSS_PTPTSTRIGSEL1_PTP_AUX_TS_TRIG_SEL1_M 0x1FU // Trigger select for
// Auxillary TS capture - 1
#define ETHERNETSS_PTPTSTRIGSEL1_WRITE_KEY_S 16U
#define ETHERNETSS_PTPTSTRIGSEL1_WRITE_KEY_M 0xFF0000U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_PTPTSSWTRIG0 register
//
//*************************************************************************************************
#define ETHERNETSS_PTPTSSWTRIG0_PTP_AUX_TS_SW_TRIG0 0x1U // SW trigger for AUX TS capture for
// trigger-0
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_PTPTSSWTRIG1 register
//
//*************************************************************************************************
#define ETHERNETSS_PTPTSSWTRIG1_PTP_AUX_TS_SW_TRIG1 0x1U // SW trigger for AUX TS capture for
// trigger-1
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_PTPPPSR0 register
//
//*************************************************************************************************
#define ETHERNETSS_PTPPPSR0_PTP_PPS_R0 0x1U // Registered value of Pulse Per Second-0
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_PTPPPSR1 register
//
//*************************************************************************************************
#define ETHERNETSS_PTPPPSR1_PTP_PPS_R1 0x1U // Registered value of Pulse Per Second-1
//*************************************************************************************************
//
// The following are defines for the bit fields in the ETHERNETSS_REVMII_CTRL register
//
//*************************************************************************************************
#define ETHERNETSS_REVMII_CTRL_REVMII_CORE_PHY_ADDR_S 0U
#define ETHERNETSS_REVMII_CTRL_REVMII_CORE_PHY_ADDR_M 0x1FU // RevMII Core Register Space
// offset
#define ETHERNETSS_REVMII_CTRL_REVMII_REMOTE_PHY_ADDR_S 8U
#define ETHERNETSS_REVMII_CTRL_REVMII_REMOTE_PHY_ADDR_M 0x1F00U // RevMII Remote Register
// Space offset
#define ETHERNETSS_REVMII_CTRL_WRITE_KEY_S 16U
#define ETHERNETSS_REVMII_CTRL_WRITE_KEY_M 0xFF0000U // Key to enable writing lock
#endif
@@ -0,0 +1,357 @@
//###########################################################################
//
// FILE: hw_esc_ss.h
//
// TITLE: Definitions for the ESCSS registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_ESC_SS_H
#define HW_ESC_SS_H
//*************************************************************************************************
//
// The following are defines for the ESCSS register offsets
//
//*************************************************************************************************
#define ESCSS_O_IPREVNUM 0x0U // IP Revision Number
#define ESCSS_O_INTR_RIS 0x4U // EtherCATSS Interrupt Raw Status
#define ESCSS_O_INTR_MASK 0x8U // EtherCATSS Interrupt Mask
#define ESCSS_O_INTR_MIS 0xCU // EtherCATSS Masked Interrupt Status
#define ESCSS_O_INTR_CLR 0x10U // EtherCATSS Interrupt Clear
#define ESCSS_O_INTR_SET 0x14U // EtherCATSS Interrupt Set to emulate
#define ESCSS_O_LATCH_SEL 0x18U // Select for Latch0/1 inputs and LATCHIN input
#define ESCSS_O_ACCESS_CTRL 0x1CU // PDI interface access control config.
#define ESCSS_O_GPIN_DAT 0x20U // GPIN data capture for debug & override
#define ESCSS_O_GPIN_PIPE 0x24U // GPIN pipeline select
#define ESCSS_O_GPIN_GRP_CAP_SEL 0x28U // GPIN pipe group capture trigger
#define ESCSS_O_GPOUT_DAT 0x2CU // GPOUT data capture for debug & override
#define ESCSS_O_GPOUT_PIPE 0x30U // GPOUT pipeline select
#define ESCSS_O_GPOUT_GRP_CAP_SEL 0x34U // GPOUT pipe group capture trigger
#define ESCSS_O_MEM_TEST 0x38U // Memory Test Control
#define ESCSS_O_RESET_DEST_CONFIG 0x3CU // ResetOut impact or destination config
#define ESCSS_O_SYNC0_CONFIG 0x40U // SYNC0 Configuration for various triggers
#define ESCSS_O_SYNC1_CONFIG 0x44U // SYNC1 Configuration for various triggers
#define ESCSS_O_CONFIG_LOCK 0x0U // EtherCATSS Configuration Lock
#define ESCSS_O_MISC_IO_CONFIG 0x4U // RESET_IN, EEPROM IO connections select
#define ESCSS_O_PHY_IO_CONFIG 0x8U // Control Register of ESCSS
#define ESCSS_O_SYNC_IO_CONFIG 0xCU // SYNC Signals IO configurations
#define ESCSS_O_LATCH_IO_CONFIG 0x10U // LATCH inputs IO pad select
#define ESCSS_O_GPIN_SEL 0x14U // GPIN Select between IO PAD & tieoff
#define ESCSS_O_GPIN_IOPAD_SEL 0x18U // GPIN IO pad Select
#define ESCSS_O_GPOUT_SEL 0x1CU // GPOUT IO pad connect select
#define ESCSS_O_GPOUT_IOPAD_SEL 0x20U // GPOUT IO pad select
#define ESCSS_O_LED_CONFIG 0x24U // Selection of LED o/p connect to IO pad
#define ESCSS_O_MISC_CONFIG 0x28U // Miscelleneous Configuration
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_IPREVNUM register
//
//*************************************************************************************************
#define ESCSS_IPREVNUM_IP_REV_MINOR_S 0U
#define ESCSS_IPREVNUM_IP_REV_MINOR_M 0xFU // Minor IP Revision Number
#define ESCSS_IPREVNUM_IP_REV_MAJOR_S 4U
#define ESCSS_IPREVNUM_IP_REV_MAJOR_M 0xF0U // Major IP Revision Number
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_INTR_RIS register
//
//*************************************************************************************************
#define ESCSS_INTR_RIS_SYNC0_RIS 0x1U // SYNC0 feature RIS
#define ESCSS_INTR_RIS_SYNC1_RIS 0x2U // SYNC1 feature RIS
#define ESCSS_INTR_RIS_IRQ_RIS 0x4U // EtherCATSS IRQ RIS
#define ESCSS_INTR_RIS_DMA_DONE_RIS 0x8U // DMA Done RIS
#define ESCSS_INTR_RIS_TIMEOUT_ERR_RIS 0x10U // PDI bus Timeout Error RIS
#define ESCSS_INTR_RIS_MASTER_RESET_RIS 0x20U // ECAT RESET RIS
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_INTR_MASK register
//
//*************************************************************************************************
#define ESCSS_INTR_MASK_SYNC0_MASK 0x1U // SYNC0 feature Mask
#define ESCSS_INTR_MASK_SYNC1_MASK 0x2U // SYNC1 feature Mask
#define ESCSS_INTR_MASK_IRQ_MASK 0x4U // EtherCATSS IRQ Mask
#define ESCSS_INTR_MASK_DMA_DONE_MASK 0x8U // DMA Done Mask
#define ESCSS_INTR_MASK_TIMEOUT_ERR_MASK 0x10U // PDI Access Timeout Error Mask
#define ESCSS_INTR_MASK_MASTER_RESET_MASK 0x20U // EtherCAT Master Reset Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_INTR_MIS register
//
//*************************************************************************************************
#define ESCSS_INTR_MIS_SYNC0_MIS 0x1U // SYNC0 feature MIS
#define ESCSS_INTR_MIS_SYNC1_MIS 0x2U // SYNC1 feature MIS
#define ESCSS_INTR_MIS_IRQ_MIS 0x4U // EtherCATSS IRQ MIS
#define ESCSS_INTR_MIS_DMA_DONE_MIS 0x8U // DMA Done MIS
#define ESCSS_INTR_MIS_TIMEOUT_ERR_MIS 0x10U // PDI bus Timeout Error MIS
#define ESCSS_INTR_MIS_MASTER_RESET_MIS 0x20U // EtherCAT Master Reset MIS
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_INTR_CLR register
//
//*************************************************************************************************
#define ESCSS_INTR_CLR_SYNC0_CLR 0x1U // SYNC0 feature Clear
#define ESCSS_INTR_CLR_SYNC1_CLR 0x2U // SYNC1 feature Clear
#define ESCSS_INTR_CLR_IRQ_CLR 0x4U // EtherCATSS IRQ Clear
#define ESCSS_INTR_CLR_DMA_DONE_CLR 0x8U // DMA Done Clear
#define ESCSS_INTR_CLR_TIMEOUT_ERR_CLR 0x10U // PDI Access Timeout Error Clear
#define ESCSS_INTR_CLR_MASTER_RESET_CLR 0x20U // EtherCAT Master Reset Clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_INTR_SET register
//
//*************************************************************************************************
#define ESCSS_INTR_SET_SYNC0_SET 0x1U // SYNC0 Set Emulate
#define ESCSS_INTR_SET_SYNC1_SET 0x2U // SYNC1 Set Emulate
#define ESCSS_INTR_SET_IRQ_SET 0x4U // EtherCATSS IRQ Set Emulate
#define ESCSS_INTR_SET_DMA_DONE_SET 0x8U // DMA Done Set Emulate
#define ESCSS_INTR_SET_TIMEOUT_ERR_SET 0x10U // PDI Access Timeout Error Set Emulate
#define ESCSS_INTR_SET_MASTER_RESET_SET 0x20U // EtherCAT Master Reset Emulate
#define ESCSS_INTR_SET_WRITE_KEY_S 8U
#define ESCSS_INTR_SET_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_LATCH_SEL register
//
//*************************************************************************************************
#define ESCSS_LATCH_SEL_LATCH0_SELECT_S 0U
#define ESCSS_LATCH_SEL_LATCH0_SELECT_M 0x1FU // LATCH0 Inputs mux select
#define ESCSS_LATCH_SEL_LATCH1_SELECT_S 8U
#define ESCSS_LATCH_SEL_LATCH1_SELECT_M 0x1F00U // LATCH1 Inputs mux select
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_ACCESS_CTRL register
//
//*************************************************************************************************
#define ESCSS_ACCESS_CTRL_WAIT_STATES_S 0U
#define ESCSS_ACCESS_CTRL_WAIT_STATES_M 0x7FU // Minimum Wait States for
// VBUS Bridge
#define ESCSS_ACCESS_CTRL_EN_TIMEOUT 0x80U // PDI Timeout enable
#define ESCSS_ACCESS_CTRL_ENABLE_DEBUG_ACCESS 0x200U // Debug access enable
#define ESCSS_ACCESS_CTRL_ENABLE_PARALLEL_PORT_ACCESS 0x400U // Parallel port access enable
#define ESCSS_ACCESS_CTRL_TIMEOUT_COUNT_S 16U
#define ESCSS_ACCESS_CTRL_TIMEOUT_COUNT_M 0xFFF0000U // Max timecount programmed
// and count while enabled.
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_GPIN_GRP_CAP_SEL register
//
//*************************************************************************************************
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL0_S 0U
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL0_M 0x7U // GPI7-0 capture trigger select
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL1_S 4U
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL1_M 0x70U // GPI15-8 capture trigger select
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL2_S 8U
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL2_M 0x700U // GPI23-16 capture trigger select
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL3_S 12U
#define ESCSS_GPIN_GRP_CAP_SEL_GPI_GRP_CAP_SEL3_M 0x7000U // GPI31-24 capture trigger select
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_GPOUT_GRP_CAP_SEL register
//
//*************************************************************************************************
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL0_S 0U
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL0_M 0x3U // GPO7-0 capture trigger select
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL1_S 4U
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL1_M 0x30U // GPO15-8 capture trigger select
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL2_S 8U
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL2_M 0x300U // GPO23-16 capture trigger select
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL3_S 12U
#define ESCSS_GPOUT_GRP_CAP_SEL_GPO_GRP_CAP_SEL3_M 0x3000U // GPO31-24 capture trigger select
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_MEM_TEST register
//
//*************************************************************************************************
#define ESCSS_MEM_TEST_INITIATE_MEM_INIT 0x1U // Initialize memory init
#define ESCSS_MEM_TEST_MEM_INIT_DONE 0x2U // Memory Init done status
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_RESET_DEST_CONFIG register
//
//*************************************************************************************************
#define ESCSS_RESET_DEST_CONFIG_CPU_RESET_EN 0x1U // CPU reset enable for ResetOut
#define ESCSS_RESET_DEST_CONFIG_CPU_NMI_EN 0x2U // CPU NMI enable for ResetOut
#define ESCSS_RESET_DEST_CONFIG_CPU_INT_EN 0x4U // CPU Interrupt enable for ResetOut
#define ESCSS_RESET_DEST_CONFIG_DEVICE_RESET_EN 0x80U // Enables RESET_OUT to impact the
// device reset
#define ESCSS_RESET_DEST_CONFIG_WRITE_KEY_S 8U
#define ESCSS_RESET_DEST_CONFIG_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_SYNC0_CONFIG register
//
//*************************************************************************************************
#define ESCSS_SYNC0_CONFIG_C28X_PIE_EN 0x1U // Connects the SYNC0 to C28x PIE Interrupt
#define ESCSS_SYNC0_CONFIG_CLA_INT_EN 0x2U // Connects the SYNC0 to CLA Interrupt
#define ESCSS_SYNC0_CONFIG_C28X_DMA_EN 0x4U // Connects the SYNC0 to C28x DMA Trigger
#define ESCSS_SYNC0_CONFIG_CM4_NVIC_EN 0x8U // Connects the SYNC0 to CM4 NVIC Interrupt
#define ESCSS_SYNC0_CONFIG_UDMA_TRIG_EN 0x10U // Connects the SYNC0 to uDMA Trigger
#define ESCSS_SYNC0_CONFIG_WRITE_KEY_S 8U
#define ESCSS_SYNC0_CONFIG_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_SYNC1_CONFIG register
//
//*************************************************************************************************
#define ESCSS_SYNC1_CONFIG_C28X_PIE_EN 0x1U // Connects the SYNC1 to C28x PIE Interrupt
#define ESCSS_SYNC1_CONFIG_CLA_INT_EN 0x2U // Connects the SYNC1 to CLA Interrupt
#define ESCSS_SYNC1_CONFIG_C28X_DMA_EN 0x4U // Connects the SYNC1 to C28x DMA Trigger
#define ESCSS_SYNC1_CONFIG_CM4_NVIC_EN 0x8U // Connects the SYNC1 to CM4 NVIC Interrupt
#define ESCSS_SYNC1_CONFIG_UDMA_TRIG_EN 0x10U // Connects the SYNC1 to uDMA Trigger
#define ESCSS_SYNC1_CONFIG_WRITE_KEY_S 8U
#define ESCSS_SYNC1_CONFIG_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_CONFIG_LOCK register
//
//*************************************************************************************************
#define ESCSS_CONFIG_LOCK_LOCK_ENABLE 0x1U // Locking writes to ECATSS
#define ESCSS_CONFIG_LOCK_IO_CONFIG_ENABLE 0x10U // Locking the IO Configuration
#define ESCSS_CONFIG_LOCK_WRITE_KEY_S 8U
#define ESCSS_CONFIG_LOCK_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_MISC_IO_CONFIG register
//
//*************************************************************************************************
#define ESCSS_MISC_IO_CONFIG_RESETIN_GPIO_EN 0x1U // Enabled ResetIN from GPIO
#define ESCSS_MISC_IO_CONFIG_EEPROM_I2C_IO_EN 0x2U // Enables the EEPROM I2C IOPAD
// connection
#define ESCSS_MISC_IO_CONFIG_WRITE_KEY_S 8U
#define ESCSS_MISC_IO_CONFIG_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_PHY_IO_CONFIG register
//
//*************************************************************************************************
#define ESCSS_PHY_IO_CONFIG_PHY_PORT_CNT_S 2U
#define ESCSS_PHY_IO_CONFIG_PHY_PORT_CNT_M 0xCU // Number of PHY port counts
#define ESCSS_PHY_IO_CONFIG_PHY_INTF_IOPAD_SEL_S 4U
#define ESCSS_PHY_IO_CONFIG_PHY_INTF_IOPAD_SEL_M 0x30U // IO Combination select for PHY
// Interface
#define ESCSS_PHY_IO_CONFIG_TX_CLK_AUTO_COMP 0x40U // Selects TX_CLK IO to do Auto
// compensation
#define ESCSS_PHY_IO_CONFIG_WRITE_KEY_S 8U
#define ESCSS_PHY_IO_CONFIG_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_SYNC_IO_CONFIG register
//
//*************************************************************************************************
#define ESCSS_SYNC_IO_CONFIG_SYNC0_IOPAD_SEL_S 0U
#define ESCSS_SYNC_IO_CONFIG_SYNC0_IOPAD_SEL_M 0x3U // SYNC0 IO PAD select option
#define ESCSS_SYNC_IO_CONFIG_SYNC0_GPIO_EN 0x8U // SYNC0 connection to OUT pad enabled
#define ESCSS_SYNC_IO_CONFIG_SYNC1_IOPAD_SEL_S 4U
#define ESCSS_SYNC_IO_CONFIG_SYNC1_IOPAD_SEL_M 0x30U // SYNC1 IO PAD select option
#define ESCSS_SYNC_IO_CONFIG_SYNC1_GPIO_EN 0x80U // SYNC1 connection to OUT pad enabled
#define ESCSS_SYNC_IO_CONFIG_WRITE_KEY_S 8U
#define ESCSS_SYNC_IO_CONFIG_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_LATCH_IO_CONFIG register
//
//*************************************************************************************************
#define ESCSS_LATCH_IO_CONFIG_LATCH0_IOPAD_SEL_S 0U
#define ESCSS_LATCH_IO_CONFIG_LATCH0_IOPAD_SEL_M 0x3U // LATCH0 IO PAD select option
#define ESCSS_LATCH_IO_CONFIG_LATCH0_GPIO_EN 0x8U // LATCH0 connection to IN pad enabled
#define ESCSS_LATCH_IO_CONFIG_LATCH1_IOPAD_SEL_S 4U
#define ESCSS_LATCH_IO_CONFIG_LATCH1_IOPAD_SEL_M 0x30U // LATCH1 IO PAD select option
#define ESCSS_LATCH_IO_CONFIG_LATCH1_GPIO_EN 0x80U // LATCH1 connection to IN pad enabled
#define ESCSS_LATCH_IO_CONFIG_WRITE_KEY_S 8U
#define ESCSS_LATCH_IO_CONFIG_WRITE_KEY_M 0xFF00U // Key to enable writing lock
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_LED_CONFIG register
//
//*************************************************************************************************
#define ESCSS_LED_CONFIG_LINKACT0 0x1U // GPIO enable for LINKACT0 LED
#define ESCSS_LED_CONFIG_LINKACT1 0x2U // GPIO enable for LINKACT1 LED
#define ESCSS_LED_CONFIG_STATE 0x4U // GPIO enable for STATE LED
#define ESCSS_LED_CONFIG_ERR 0x8U // GPIO enable for ERR LED
#define ESCSS_LED_CONFIG_RUN 0x10U // GPIO enable for RUN LED
#define ESCSS_LED_CONFIG_LINKACT0_IOPAD_SEL_S 6U
#define ESCSS_LED_CONFIG_LINKACT0_IOPAD_SEL_M 0xC0U // LINKACT0 LED IO PAD select
#define ESCSS_LED_CONFIG_LINKACT1_IOPAD_SEL_S 8U
#define ESCSS_LED_CONFIG_LINKACT1_IOPAD_SEL_M 0x300U // LINKACT1 LED IO PAD select
#define ESCSS_LED_CONFIG_STATE_IOPAD_SEL_S 10U
#define ESCSS_LED_CONFIG_STATE_IOPAD_SEL_M 0xC00U // STATE LED IO PAD select
#define ESCSS_LED_CONFIG_ERR_IOPAD_SEL_S 12U
#define ESCSS_LED_CONFIG_ERR_IOPAD_SEL_M 0x3000U // ERROR LED IO PAD select
#define ESCSS_LED_CONFIG_RUN_IOPAD_SEL_S 14U
#define ESCSS_LED_CONFIG_RUN_IOPAD_SEL_M 0xC000U // RUN LED IO PAD select
//*************************************************************************************************
//
// The following are defines for the bit fields in the ESCSS_MISC_CONFIG register
//
//*************************************************************************************************
#define ESCSS_MISC_CONFIG_TX0_SHIFT_CONFIG_S 0U
#define ESCSS_MISC_CONFIG_TX0_SHIFT_CONFIG_M 0x3U // TX Shift configuration for Port0
#define ESCSS_MISC_CONFIG_TX1_SHIFT_CONFIG_S 2U
#define ESCSS_MISC_CONFIG_TX1_SHIFT_CONFIG_M 0xCU // TX Shift configuration for Port1
#define ESCSS_MISC_CONFIG_EEPROM_SIZE 0x10U // EEPROM Size bound select
#define ESCSS_MISC_CONFIG_PDI_EMULATION 0x20U // PDI Emulation enable
#define ESCSS_MISC_CONFIG_PHY_ADDR_S 6U
#define ESCSS_MISC_CONFIG_PHY_ADDR_M 0x7C0U // PHY Address Offset
#endif
@@ -0,0 +1,275 @@
//###########################################################################
//
// FILE: hw_flash.h
//
// TITLE: Definitions for the FLASH registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_FLASH_H
#define HW_FLASH_H
//*************************************************************************************************
//
// The following are defines for the FLASH register offsets
//
//*************************************************************************************************
#define FLASH_O_FRDCNTL 0x0U // Flash Read Control Register
#define FLASH_O_FBAC 0x3CU // Flash Bank Access Control Register
#define FLASH_O_FBFALLBACK 0x40U // Flash Bank Fallback Power Register
#define FLASH_O_FBPRDY 0x44U // Flash Bank Pump Ready Register
#define FLASH_O_FPAC1 0x48U // Flash Pump Access Control Register 1
#define FLASH_O_FMSTAT 0x54U // Flash Module Status Register
#define FLASH_O_FRD_INTF_CTRL_LOCK 0x2FCU // Lock register for FLASH_CTRL_REGS (Not including
// FRD_INTF_CTRL_LOCK ).
#define FLASH_O_FRD_INTF_CTRL 0x300U // Flash Read Interface Control Register
#define FLASH_O_ECC_ENABLE 0x0U // ECC Enable
#define FLASH_O_SINGLE_ERR_ADDR_LOW 0x4U // Single Error Address Low
#define FLASH_O_SINGLE_ERR_ADDR_HIGH 0x8U // Single Error Address High
#define FLASH_O_UNC_ERR_ADDR_LOW 0xCU // Uncorrectable Error Address Low
#define FLASH_O_UNC_ERR_ADDR_HIGH 0x10U // Uncorrectable Error Address High
#define FLASH_O_ERR_STATUS 0x14U // Error Status
#define FLASH_O_ERR_POS 0x18U // Error Position
#define FLASH_O_ERR_STATUS_CLR 0x1CU // Error Status Clear
#define FLASH_O_ERR_CNT 0x20U // Error Control
#define FLASH_O_ERR_THRESHOLD 0x24U // Error Threshold
#define FLASH_O_ERR_INTFLG 0x28U // Error Interrupt Flag
#define FLASH_O_ERR_INTCLR 0x2CU // Error Interrupt Flag Clear
#define FLASH_O_FDATAH_TEST 0x30U // Data High Test
#define FLASH_O_FDATAL_TEST 0x34U // Data Low Test
#define FLASH_O_FADDR_TEST 0x38U // ECC Test Address
#define FLASH_O_FECC_TEST 0x3CU // ECC Test Address
#define FLASH_O_FECC_CTRL 0x40U // ECC Control
#define FLASH_O_FOUTH_TEST 0x44U // Test Data Out High
#define FLASH_O_FOUTL_TEST 0x48U // Test Data Out Low
#define FLASH_O_FECC_STATUS 0x4CU // ECC Status
#define FLASH_O_ECC_REGS_LOCK 0x7CU // Lock register for FLASH_ECC_REGS (Not including
// FLASH_ECC_REGS_LOCK ).
//*************************************************************************************************
//
// The following are defines for the bit fields in the FRDCNTL register
//
//*************************************************************************************************
#define FLASH_FRDCNTL_RWAIT_S 8U
#define FLASH_FRDCNTL_RWAIT_M 0xF00U // Random Read Waitstate
//*************************************************************************************************
//
// The following are defines for the bit fields in the FBAC register
//
//*************************************************************************************************
#define FLASH_FBAC_BAGP_S 8U
#define FLASH_FBAC_BAGP_M 0xFF00U // Bank Active Grace Period
//*************************************************************************************************
//
// The following are defines for the bit fields in the FBFALLBACK register
//
//*************************************************************************************************
#define FLASH_FBFALLBACK_BNKPWR0_S 0U
#define FLASH_FBFALLBACK_BNKPWR0_M 0x3U // Bank Power Mode of BANK0
//*************************************************************************************************
//
// The following are defines for the bit fields in the FBPRDY register
//
//*************************************************************************************************
#define FLASH_FBPRDY_BANKRDY 0x1U // Flash Bank Active Power State
#define FLASH_FBPRDY_PUMPRDY 0x8000U // Flash Pump Active Power Mode
//*************************************************************************************************
//
// The following are defines for the bit fields in the FPAC1 register
//
//*************************************************************************************************
#define FLASH_FPAC1_PMPPWR 0x1U // Charge Pump Fallback Power Mode
#define FLASH_FPAC1_PSLEEP_S 16U
#define FLASH_FPAC1_PSLEEP_M 0xFFF0000U // Pump Sleep Down Count
//*************************************************************************************************
//
// The following are defines for the bit fields in the FMSTAT register
//
//*************************************************************************************************
#define FLASH_FMSTAT_PSUSP 0x2U // Program Suspend.
#define FLASH_FMSTAT_ESUSP 0x4U // Erase Suspend.
#define FLASH_FMSTAT_VOLTSTAT 0x8U // Core Voltage Status.
#define FLASH_FMSTAT_CSTAT 0x10U // Command Status.
#define FLASH_FMSTAT_INVDAT 0x20U // Invalid Data.
#define FLASH_FMSTAT_PGM 0x40U // Program Active.
#define FLASH_FMSTAT_ERS 0x80U // Erase Active.
#define FLASH_FMSTAT_BUSY 0x100U // Busy Bit.
#define FLASH_FMSTAT_EV 0x400U // Erase verify
#define FLASH_FMSTAT_PGV 0x1000U // Program verify
//*************************************************************************************************
//
// The following are defines for the bit fields in the FRD_INTF_CTRL register
//
//*************************************************************************************************
#define FLASH_FRD_INTF_CTRL_PROG_CACHE_EN 0x1U // Program Cache Enable
#define FLASH_FRD_INTF_CTRL_DATA_CACHE_EN 0x2U // Data Cache Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the ECC_ENABLE register
//
//*************************************************************************************************
#define FLASH_ECC_ENABLE_ENABLE_S 0U
#define FLASH_ECC_ENABLE_ENABLE_M 0xFU // Enable ECC
//*************************************************************************************************
//
// The following are defines for the bit fields in the ERR_STATUS register
//
//*************************************************************************************************
#define FLASH_ERR_STATUS_FAIL_0_L 0x1U // Lower 64bits Single Bit Error Corrected Value 0
#define FLASH_ERR_STATUS_FAIL_1_L 0x2U // Lower 64bits Single Bit Error Corrected Value 1
#define FLASH_ERR_STATUS_UNC_ERR_L 0x4U // Lower 64 bits Uncorrectable error occurred
#define FLASH_ERR_STATUS_FAIL_0_H 0x10000U // Upper 64bits Single Bit Error Corrected Value 0
#define FLASH_ERR_STATUS_FAIL_1_H 0x20000U // Upper 64bits Single Bit Error Corrected Value 1
#define FLASH_ERR_STATUS_UNC_ERR_H 0x40000U // Upper 64 bits Uncorrectable error occurred
//*************************************************************************************************
//
// The following are defines for the bit fields in the ERR_POS register
//
//*************************************************************************************************
#define FLASH_ERR_POS_ERR_POS_L_S 0U
#define FLASH_ERR_POS_ERR_POS_L_M 0x3FU // Bit Position of Single bit Error in lower 64
// bits
#define FLASH_ERR_POS_ERR_TYPE_L 0x100U // Error Type in lower 64 bits
#define FLASH_ERR_POS_ERR_POS_H_S 16U
#define FLASH_ERR_POS_ERR_POS_H_M 0x3F0000U // Bit Position of Single bit Error in upper 64
// bits
#define FLASH_ERR_POS_ERR_TYPE_H 0x1000000U // Error Type in upper 64 bits
//*************************************************************************************************
//
// The following are defines for the bit fields in the ERR_STATUS_CLR register
//
//*************************************************************************************************
#define FLASH_ERR_STATUS_CLR_FAIL_0_L_CLR 0x1U // Lower 64bits Single Bit Error Corrected
// Value 0 Clear
#define FLASH_ERR_STATUS_CLR_FAIL_1_L_CLR 0x2U // Lower 64bits Single Bit Error Corrected
// Value 1 Clear
#define FLASH_ERR_STATUS_CLR_UNC_ERR_L_CLR 0x4U // Lower 64 bits Uncorrectable error
// occurred Clear
#define FLASH_ERR_STATUS_CLR_FAIL_0_H_CLR 0x10000U // Upper 64bits Single Bit Error Corrected
// Value 0 Clear
#define FLASH_ERR_STATUS_CLR_FAIL_1_H_CLR 0x20000U // Upper 64bits Single Bit Error Corrected
// Value 1 Clear
#define FLASH_ERR_STATUS_CLR_UNC_ERR_H_CLR 0x40000U // Upper 64 bits Uncorrectable error
// occurred Clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the ERR_CNT register
//
//*************************************************************************************************
#define FLASH_ERR_CNT_ERR_CNT_S 0U
#define FLASH_ERR_CNT_ERR_CNT_M 0xFFFFU // Error counter
//*************************************************************************************************
//
// The following are defines for the bit fields in the ERR_THRESHOLD register
//
//*************************************************************************************************
#define FLASH_ERR_THRESHOLD_ERR_THRESHOLD_S 0U
#define FLASH_ERR_THRESHOLD_ERR_THRESHOLD_M 0xFFFFU // Error Threshold
//*************************************************************************************************
//
// The following are defines for the bit fields in the ERR_INTFLG register
//
//*************************************************************************************************
#define FLASH_ERR_INTFLG_SINGLE_ERR_INTFLG 0x1U // Single Error Interrupt Flag
#define FLASH_ERR_INTFLG_UNC_ERR_INTFLG 0x2U // Uncorrectable Interrupt Flag
//*************************************************************************************************
//
// The following are defines for the bit fields in the ERR_INTCLR register
//
//*************************************************************************************************
#define FLASH_ERR_INTCLR_SINGLE_ERR_INTCLR 0x1U // Single Error Interrupt Flag Clear
#define FLASH_ERR_INTCLR_UNC_ERR_INTCLR 0x2U // Uncorrectable Interrupt Flag Clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the FADDR_TEST register
//
//*************************************************************************************************
#define FLASH_FADDR_TEST_ADDRL_S 3U
#define FLASH_FADDR_TEST_ADDRL_M 0xFFF8U // ECC Address Low
#define FLASH_FADDR_TEST_ADDRH_S 16U
#define FLASH_FADDR_TEST_ADDRH_M 0x3F0000U // ECC Address High
//*************************************************************************************************
//
// The following are defines for the bit fields in the FECC_TEST register
//
//*************************************************************************************************
#define FLASH_FECC_TEST_ECC_S 0U
#define FLASH_FECC_TEST_ECC_M 0xFFU // ECC Control Bits
//*************************************************************************************************
//
// The following are defines for the bit fields in the FECC_CTRL register
//
//*************************************************************************************************
#define FLASH_FECC_CTRL_ECC_TEST_EN 0x1U // Enable ECC Test Logic
#define FLASH_FECC_CTRL_ECC_SELECT 0x2U // ECC Bit Select
#define FLASH_FECC_CTRL_DO_ECC_CALC 0x4U // Enable ECC Calculation
//*************************************************************************************************
//
// The following are defines for the bit fields in the FECC_STATUS register
//
//*************************************************************************************************
#define FLASH_FECC_STATUS_SINGLE_ERR 0x1U // Test Result is Single Bit Error
#define FLASH_FECC_STATUS_UNC_ERR 0x2U // Test Result is Uncorrectable Error
#define FLASH_FECC_STATUS_DATA_ERR_POS_S 2U
#define FLASH_FECC_STATUS_DATA_ERR_POS_M 0xFCU // Holds Bit Position of Error
#define FLASH_FECC_STATUS_ERR_TYPE 0x100U // Holds Bit Position of 8 Check Bits of Error
#endif
@@ -0,0 +1,83 @@
//###########################################################################
//
// FILE: hw_gcrc.h
//
// TITLE: Definitions for the GCRC registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_GCRC_H
#define HW_GCRC_H
//*************************************************************************************************
//
// The following are defines for the GCRC register offsets
//
//*************************************************************************************************
#define GCRC_O_CRCCTRL 0x0U // CRC Control Register
#define GCRC_O_CRCPOLY 0x4U // CRC Polynomial Register
#define GCRC_O_CRCDATAMASK 0x8U // CRC Data Mask Register
#define GCRC_O_CRCDATAIN 0xCU // CRC Data Input Register
#define GCRC_O_CRCDATAOUT 0x10U // CRC Data Output Register
#define GCRC_O_CRCDATATRANS 0x14U // CRC Transformed Data Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the CRCCTRL register
//
//*************************************************************************************************
#define GCRC_CRCCTRL_POLYSIZE_S 0U
#define GCRC_CRCCTRL_POLYSIZE_M 0x3FU // CRC polynomial order
#define GCRC_CRCCTRL_ENDIANNESS 0x40U // Defines the endianness of the data stream.
#define GCRC_CRCCTRL_BITREVERSE 0x80U // Enables the DATAIN bus to the CRC engine to be bit
// reversed.
#define GCRC_CRCCTRL_DATATYPE_S 8U
#define GCRC_CRCCTRL_DATATYPE_M 0x300U // Defines the DATATYPE of the element of the data
// array.
//*************************************************************************************************
//
// The following are defines for the bit fields in the CRCDATAMASK register
//
//*************************************************************************************************
#define GCRC_CRCDATAMASK_DATAMASK_S 0U
#define GCRC_CRCDATAMASK_DATAMASK_M 0x1FU // Number of bits to be masked
#endif
@@ -0,0 +1,909 @@
//###########################################################################
//
// FILE: hw_gpio.h
//
// TITLE: Definitions for the GPIO registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_GPIO_H
#define HW_GPIO_H
//*************************************************************************************************
//
// The following are defines for the GPIO register offsets
//
//*************************************************************************************************
#define GPIO_O_GPADAT 0x0U // GPIO A Data Register (GPIO0 to 31)
#define GPIO_O_GPASET 0x4U // GPIO A Data Set Register (GPIO0 to 31)
#define GPIO_O_GPACLEAR 0x8U // GPIO A Data Clear Register (GPIO0 to 31)
#define GPIO_O_GPATOGGLE 0xCU // GPIO A Data Toggle Register (GPIO0 to 31)
#define GPIO_O_GPBDAT 0x10U // GPIO B Data Register (GPIO32 to 63)
#define GPIO_O_GPBSET 0x14U // GPIO B Data Set Register (GPIO32 to 63)
#define GPIO_O_GPBCLEAR 0x18U // GPIO B Data Clear Register (GPIO32 to 63)
#define GPIO_O_GPBTOGGLE 0x1CU // GPIO B Data Toggle Register (GPIO32 to 63)
#define GPIO_O_GPCDAT 0x20U // GPIO C Data Register (GPIO64 to 95)
#define GPIO_O_GPCSET 0x24U // GPIO C Data Set Register (GPIO64 to 95)
#define GPIO_O_GPCCLEAR 0x28U // GPIO C Data Clear Register (GPIO64 to 95)
#define GPIO_O_GPCTOGGLE 0x2CU // GPIO C Data Toggle Register (GPIO64 to 95)
#define GPIO_O_GPDDAT 0x30U // GPIO D Data Register (GPIO96 to 127)
#define GPIO_O_GPDSET 0x34U // GPIO D Data Set Register (GPIO96 to 127)
#define GPIO_O_GPDCLEAR 0x38U // GPIO D Data Clear Register (GPIO96 to 127)
#define GPIO_O_GPDTOGGLE 0x3CU // GPIO D Data Toggle Register (GPIO96 to 127)
#define GPIO_O_GPEDAT 0x40U // GPIO E Data Register (GPIO128 to 159)
#define GPIO_O_GPESET 0x44U // GPIO E Data Set Register (GPIO128 to 159)
#define GPIO_O_GPECLEAR 0x48U // GPIO E Data Clear Register (GPIO128 to 159)
#define GPIO_O_GPETOGGLE 0x4CU // GPIO E Data Toggle Register (GPIO128 to 159)
#define GPIO_O_GPFDAT 0x50U // GPIO F Data Register (GPIO160 to 191)
#define GPIO_O_GPFSET 0x54U // GPIO F Data Set Register (GPIO160 to 191)
#define GPIO_O_GPFCLEAR 0x58U // GPIO F Data Clear Register (GPIO160 to 191)
#define GPIO_O_GPFTOGGLE 0x5CU // GPIO F Data Toggle Register (GPIO160 to 191)
#define GPIO_O_GPADAT_R 0x0U // GPIO A Data Read Register
#define GPIO_O_GPBDAT_R 0x4U // GPIO B Data Read Register
#define GPIO_O_GPCDAT_R 0x8U // GPIO C Data Read Register
#define GPIO_O_GPDDAT_R 0xCU // GPIO D Data Read Register
#define GPIO_O_GPEDAT_R 0x10U // GPIO E Data Read Register
#define GPIO_O_GPFDAT_R 0x14U // GPIO F Data Read Register
#define GPIO_O_GPGDAT_R 0x18U // GPIO G Data Read Register
#define GPIO_O_GPHDAT_R 0x1CU // GPIO H Data Read Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPADAT register
//
//*************************************************************************************************
#define GPIO_GPADAT_GPIO0 0x1U // Data Register for this pin
#define GPIO_GPADAT_GPIO1 0x2U // Data Register for this pin
#define GPIO_GPADAT_GPIO2 0x4U // Data Register for this pin
#define GPIO_GPADAT_GPIO3 0x8U // Data Register for this pin
#define GPIO_GPADAT_GPIO4 0x10U // Data Register for this pin
#define GPIO_GPADAT_GPIO5 0x20U // Data Register for this pin
#define GPIO_GPADAT_GPIO6 0x40U // Data Register for this pin
#define GPIO_GPADAT_GPIO7 0x80U // Data Register for this pin
#define GPIO_GPADAT_GPIO8 0x100U // Data Register for this pin
#define GPIO_GPADAT_GPIO9 0x200U // Data Register for this pin
#define GPIO_GPADAT_GPIO10 0x400U // Data Register for this pin
#define GPIO_GPADAT_GPIO11 0x800U // Data Register for this pin
#define GPIO_GPADAT_GPIO12 0x1000U // Data Register for this pin
#define GPIO_GPADAT_GPIO13 0x2000U // Data Register for this pin
#define GPIO_GPADAT_GPIO14 0x4000U // Data Register for this pin
#define GPIO_GPADAT_GPIO15 0x8000U // Data Register for this pin
#define GPIO_GPADAT_GPIO16 0x10000U // Data Register for this pin
#define GPIO_GPADAT_GPIO17 0x20000U // Data Register for this pin
#define GPIO_GPADAT_GPIO18 0x40000U // Data Register for this pin
#define GPIO_GPADAT_GPIO19 0x80000U // Data Register for this pin
#define GPIO_GPADAT_GPIO20 0x100000U // Data Register for this pin
#define GPIO_GPADAT_GPIO21 0x200000U // Data Register for this pin
#define GPIO_GPADAT_GPIO22 0x400000U // Data Register for this pin
#define GPIO_GPADAT_GPIO23 0x800000U // Data Register for this pin
#define GPIO_GPADAT_GPIO24 0x1000000U // Data Register for this pin
#define GPIO_GPADAT_GPIO25 0x2000000U // Data Register for this pin
#define GPIO_GPADAT_GPIO26 0x4000000U // Data Register for this pin
#define GPIO_GPADAT_GPIO27 0x8000000U // Data Register for this pin
#define GPIO_GPADAT_GPIO28 0x10000000U // Data Register for this pin
#define GPIO_GPADAT_GPIO29 0x20000000U // Data Register for this pin
#define GPIO_GPADAT_GPIO30 0x40000000U // Data Register for this pin
#define GPIO_GPADAT_GPIO31 0x80000000U // Data Register for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPASET register
//
//*************************************************************************************************
#define GPIO_GPASET_GPIO0 0x1U // Output Set bit for this pin
#define GPIO_GPASET_GPIO1 0x2U // Output Set bit for this pin
#define GPIO_GPASET_GPIO2 0x4U // Output Set bit for this pin
#define GPIO_GPASET_GPIO3 0x8U // Output Set bit for this pin
#define GPIO_GPASET_GPIO4 0x10U // Output Set bit for this pin
#define GPIO_GPASET_GPIO5 0x20U // Output Set bit for this pin
#define GPIO_GPASET_GPIO6 0x40U // Output Set bit for this pin
#define GPIO_GPASET_GPIO7 0x80U // Output Set bit for this pin
#define GPIO_GPASET_GPIO8 0x100U // Output Set bit for this pin
#define GPIO_GPASET_GPIO9 0x200U // Output Set bit for this pin
#define GPIO_GPASET_GPIO10 0x400U // Output Set bit for this pin
#define GPIO_GPASET_GPIO11 0x800U // Output Set bit for this pin
#define GPIO_GPASET_GPIO12 0x1000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO13 0x2000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO14 0x4000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO15 0x8000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO16 0x10000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO17 0x20000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO18 0x40000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO19 0x80000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO20 0x100000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO21 0x200000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO22 0x400000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO23 0x800000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO24 0x1000000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO25 0x2000000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO26 0x4000000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO27 0x8000000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO28 0x10000000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO29 0x20000000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO30 0x40000000U // Output Set bit for this pin
#define GPIO_GPASET_GPIO31 0x80000000U // Output Set bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPACLEAR register
//
//*************************************************************************************************
#define GPIO_GPACLEAR_GPIO0 0x1U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO1 0x2U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO2 0x4U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO3 0x8U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO4 0x10U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO5 0x20U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO6 0x40U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO7 0x80U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO8 0x100U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO9 0x200U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO10 0x400U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO11 0x800U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO12 0x1000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO13 0x2000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO14 0x4000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO15 0x8000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO16 0x10000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO17 0x20000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO18 0x40000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO19 0x80000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO20 0x100000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO21 0x200000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO22 0x400000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO23 0x800000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO24 0x1000000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO25 0x2000000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO26 0x4000000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO27 0x8000000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO28 0x10000000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO29 0x20000000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO30 0x40000000U // Output Clear bit for this pin
#define GPIO_GPACLEAR_GPIO31 0x80000000U // Output Clear bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPATOGGLE register
//
//*************************************************************************************************
#define GPIO_GPATOGGLE_GPIO0 0x1U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO1 0x2U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO2 0x4U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO3 0x8U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO4 0x10U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO5 0x20U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO6 0x40U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO7 0x80U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO8 0x100U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO9 0x200U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO10 0x400U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO11 0x800U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO12 0x1000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO13 0x2000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO14 0x4000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO15 0x8000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO16 0x10000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO17 0x20000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO18 0x40000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO19 0x80000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO20 0x100000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO21 0x200000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO22 0x400000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO23 0x800000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO24 0x1000000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO25 0x2000000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO26 0x4000000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO27 0x8000000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO28 0x10000000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO29 0x20000000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO30 0x40000000U // Output Toggle bit for this pin
#define GPIO_GPATOGGLE_GPIO31 0x80000000U // Output Toggle bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPBDAT register
//
//*************************************************************************************************
#define GPIO_GPBDAT_GPIO32 0x1U // Data Register for this pin
#define GPIO_GPBDAT_GPIO33 0x2U // Data Register for this pin
#define GPIO_GPBDAT_GPIO34 0x4U // Data Register for this pin
#define GPIO_GPBDAT_GPIO35 0x8U // Data Register for this pin
#define GPIO_GPBDAT_GPIO36 0x10U // Data Register for this pin
#define GPIO_GPBDAT_GPIO37 0x20U // Data Register for this pin
#define GPIO_GPBDAT_GPIO38 0x40U // Data Register for this pin
#define GPIO_GPBDAT_GPIO39 0x80U // Data Register for this pin
#define GPIO_GPBDAT_GPIO40 0x100U // Data Register for this pin
#define GPIO_GPBDAT_GPIO41 0x200U // Data Register for this pin
#define GPIO_GPBDAT_GPIO42 0x400U // Data Register for this pin
#define GPIO_GPBDAT_GPIO43 0x800U // Data Register for this pin
#define GPIO_GPBDAT_GPIO44 0x1000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO45 0x2000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO46 0x4000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO47 0x8000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO48 0x10000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO49 0x20000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO50 0x40000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO51 0x80000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO52 0x100000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO53 0x200000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO54 0x400000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO55 0x800000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO56 0x1000000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO57 0x2000000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO58 0x4000000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO59 0x8000000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO60 0x10000000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO61 0x20000000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO62 0x40000000U // Data Register for this pin
#define GPIO_GPBDAT_GPIO63 0x80000000U // Data Register for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPBSET register
//
//*************************************************************************************************
#define GPIO_GPBSET_GPIO32 0x1U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO33 0x2U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO34 0x4U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO35 0x8U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO36 0x10U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO37 0x20U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO38 0x40U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO39 0x80U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO40 0x100U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO41 0x200U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO42 0x400U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO43 0x800U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO44 0x1000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO45 0x2000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO46 0x4000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO47 0x8000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO48 0x10000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO49 0x20000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO50 0x40000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO51 0x80000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO52 0x100000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO53 0x200000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO54 0x400000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO55 0x800000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO56 0x1000000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO57 0x2000000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO58 0x4000000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO59 0x8000000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO60 0x10000000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO61 0x20000000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO62 0x40000000U // Output Set bit for this pin
#define GPIO_GPBSET_GPIO63 0x80000000U // Output Set bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPBCLEAR register
//
//*************************************************************************************************
#define GPIO_GPBCLEAR_GPIO32 0x1U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO33 0x2U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO34 0x4U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO35 0x8U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO36 0x10U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO37 0x20U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO38 0x40U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO39 0x80U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO40 0x100U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO41 0x200U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO42 0x400U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO43 0x800U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO44 0x1000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO45 0x2000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO46 0x4000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO47 0x8000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO48 0x10000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO49 0x20000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO50 0x40000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO51 0x80000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO52 0x100000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO53 0x200000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO54 0x400000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO55 0x800000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO56 0x1000000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO57 0x2000000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO58 0x4000000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO59 0x8000000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO60 0x10000000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO61 0x20000000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO62 0x40000000U // Output Clear bit for this pin
#define GPIO_GPBCLEAR_GPIO63 0x80000000U // Output Clear bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPBTOGGLE register
//
//*************************************************************************************************
#define GPIO_GPBTOGGLE_GPIO32 0x1U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO33 0x2U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO34 0x4U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO35 0x8U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO36 0x10U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO37 0x20U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO38 0x40U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO39 0x80U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO40 0x100U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO41 0x200U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO42 0x400U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO43 0x800U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO44 0x1000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO45 0x2000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO46 0x4000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO47 0x8000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO48 0x10000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO49 0x20000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO50 0x40000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO51 0x80000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO52 0x100000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO53 0x200000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO54 0x400000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO55 0x800000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO56 0x1000000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO57 0x2000000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO58 0x4000000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO59 0x8000000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO60 0x10000000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO61 0x20000000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO62 0x40000000U // Output Toggle bit for this pin
#define GPIO_GPBTOGGLE_GPIO63 0x80000000U // Output Toggle bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPCDAT register
//
//*************************************************************************************************
#define GPIO_GPCDAT_GPIO64 0x1U // Data Register for this pin
#define GPIO_GPCDAT_GPIO65 0x2U // Data Register for this pin
#define GPIO_GPCDAT_GPIO66 0x4U // Data Register for this pin
#define GPIO_GPCDAT_GPIO67 0x8U // Data Register for this pin
#define GPIO_GPCDAT_GPIO68 0x10U // Data Register for this pin
#define GPIO_GPCDAT_GPIO69 0x20U // Data Register for this pin
#define GPIO_GPCDAT_GPIO70 0x40U // Data Register for this pin
#define GPIO_GPCDAT_GPIO71 0x80U // Data Register for this pin
#define GPIO_GPCDAT_GPIO72 0x100U // Data Register for this pin
#define GPIO_GPCDAT_GPIO73 0x200U // Data Register for this pin
#define GPIO_GPCDAT_GPIO74 0x400U // Data Register for this pin
#define GPIO_GPCDAT_GPIO75 0x800U // Data Register for this pin
#define GPIO_GPCDAT_GPIO76 0x1000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO77 0x2000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO78 0x4000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO79 0x8000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO80 0x10000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO81 0x20000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO82 0x40000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO83 0x80000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO84 0x100000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO85 0x200000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO86 0x400000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO87 0x800000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO88 0x1000000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO89 0x2000000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO90 0x4000000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO91 0x8000000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO92 0x10000000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO93 0x20000000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO94 0x40000000U // Data Register for this pin
#define GPIO_GPCDAT_GPIO95 0x80000000U // Data Register for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPCSET register
//
//*************************************************************************************************
#define GPIO_GPCSET_GPIO64 0x1U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO65 0x2U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO66 0x4U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO67 0x8U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO68 0x10U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO69 0x20U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO70 0x40U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO71 0x80U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO72 0x100U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO73 0x200U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO74 0x400U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO75 0x800U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO76 0x1000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO77 0x2000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO78 0x4000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO79 0x8000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO80 0x10000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO81 0x20000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO82 0x40000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO83 0x80000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO84 0x100000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO85 0x200000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO86 0x400000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO87 0x800000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO88 0x1000000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO89 0x2000000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO90 0x4000000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO91 0x8000000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO92 0x10000000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO93 0x20000000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO94 0x40000000U // Output Set bit for this pin
#define GPIO_GPCSET_GPIO95 0x80000000U // Output Set bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPCCLEAR register
//
//*************************************************************************************************
#define GPIO_GPCCLEAR_GPIO64 0x1U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO65 0x2U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO66 0x4U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO67 0x8U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO68 0x10U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO69 0x20U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO70 0x40U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO71 0x80U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO72 0x100U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO73 0x200U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO74 0x400U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO75 0x800U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO76 0x1000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO77 0x2000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO78 0x4000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO79 0x8000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO80 0x10000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO81 0x20000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO82 0x40000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO83 0x80000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO84 0x100000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO85 0x200000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO86 0x400000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO87 0x800000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO88 0x1000000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO89 0x2000000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO90 0x4000000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO91 0x8000000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO92 0x10000000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO93 0x20000000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO94 0x40000000U // Output Clear bit for this pin
#define GPIO_GPCCLEAR_GPIO95 0x80000000U // Output Clear bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPCTOGGLE register
//
//*************************************************************************************************
#define GPIO_GPCTOGGLE_GPIO64 0x1U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO65 0x2U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO66 0x4U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO67 0x8U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO68 0x10U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO69 0x20U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO70 0x40U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO71 0x80U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO72 0x100U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO73 0x200U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO74 0x400U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO75 0x800U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO76 0x1000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO77 0x2000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO78 0x4000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO79 0x8000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO80 0x10000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO81 0x20000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO82 0x40000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO83 0x80000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO84 0x100000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO85 0x200000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO86 0x400000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO87 0x800000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO88 0x1000000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO89 0x2000000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO90 0x4000000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO91 0x8000000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO92 0x10000000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO93 0x20000000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO94 0x40000000U // Output Toggle bit for this pin
#define GPIO_GPCTOGGLE_GPIO95 0x80000000U // Output Toggle bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPDDAT register
//
//*************************************************************************************************
#define GPIO_GPDDAT_GPIO96 0x1U // Data Register for this pin
#define GPIO_GPDDAT_GPIO97 0x2U // Data Register for this pin
#define GPIO_GPDDAT_GPIO98 0x4U // Data Register for this pin
#define GPIO_GPDDAT_GPIO99 0x8U // Data Register for this pin
#define GPIO_GPDDAT_GPIO100 0x10U // Data Register for this pin
#define GPIO_GPDDAT_GPIO101 0x20U // Data Register for this pin
#define GPIO_GPDDAT_GPIO102 0x40U // Data Register for this pin
#define GPIO_GPDDAT_GPIO103 0x80U // Data Register for this pin
#define GPIO_GPDDAT_GPIO104 0x100U // Data Register for this pin
#define GPIO_GPDDAT_GPIO105 0x200U // Data Register for this pin
#define GPIO_GPDDAT_GPIO106 0x400U // Data Register for this pin
#define GPIO_GPDDAT_GPIO107 0x800U // Data Register for this pin
#define GPIO_GPDDAT_GPIO108 0x1000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO109 0x2000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO110 0x4000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO111 0x8000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO112 0x10000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO113 0x20000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO114 0x40000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO115 0x80000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO116 0x100000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO117 0x200000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO118 0x400000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO119 0x800000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO120 0x1000000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO121 0x2000000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO122 0x4000000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO123 0x8000000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO124 0x10000000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO125 0x20000000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO126 0x40000000U // Data Register for this pin
#define GPIO_GPDDAT_GPIO127 0x80000000U // Data Register for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPDSET register
//
//*************************************************************************************************
#define GPIO_GPDSET_GPIO96 0x1U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO97 0x2U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO98 0x4U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO99 0x8U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO100 0x10U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO101 0x20U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO102 0x40U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO103 0x80U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO104 0x100U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO105 0x200U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO106 0x400U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO107 0x800U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO108 0x1000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO109 0x2000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO110 0x4000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO111 0x8000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO112 0x10000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO113 0x20000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO114 0x40000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO115 0x80000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO116 0x100000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO117 0x200000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO118 0x400000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO119 0x800000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO120 0x1000000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO121 0x2000000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO122 0x4000000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO123 0x8000000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO124 0x10000000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO125 0x20000000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO126 0x40000000U // Output Set bit for this pin
#define GPIO_GPDSET_GPIO127 0x80000000U // Output Set bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPDCLEAR register
//
//*************************************************************************************************
#define GPIO_GPDCLEAR_GPIO96 0x1U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO97 0x2U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO98 0x4U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO99 0x8U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO100 0x10U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO101 0x20U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO102 0x40U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO103 0x80U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO104 0x100U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO105 0x200U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO106 0x400U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO107 0x800U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO108 0x1000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO109 0x2000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO110 0x4000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO111 0x8000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO112 0x10000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO113 0x20000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO114 0x40000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO115 0x80000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO116 0x100000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO117 0x200000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO118 0x400000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO119 0x800000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO120 0x1000000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO121 0x2000000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO122 0x4000000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO123 0x8000000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO124 0x10000000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO125 0x20000000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO126 0x40000000U // Output Clear bit for this pin
#define GPIO_GPDCLEAR_GPIO127 0x80000000U // Output Clear bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPDTOGGLE register
//
//*************************************************************************************************
#define GPIO_GPDTOGGLE_GPIO96 0x1U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO97 0x2U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO98 0x4U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO99 0x8U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO100 0x10U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO101 0x20U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO102 0x40U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO103 0x80U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO104 0x100U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO105 0x200U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO106 0x400U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO107 0x800U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO108 0x1000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO109 0x2000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO110 0x4000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO111 0x8000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO112 0x10000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO113 0x20000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO114 0x40000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO115 0x80000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO116 0x100000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO117 0x200000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO118 0x400000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO119 0x800000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO120 0x1000000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO121 0x2000000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO122 0x4000000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO123 0x8000000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO124 0x10000000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO125 0x20000000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO126 0x40000000U // Output Toggle bit for this pin
#define GPIO_GPDTOGGLE_GPIO127 0x80000000U // Output Toggle bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPEDAT register
//
//*************************************************************************************************
#define GPIO_GPEDAT_GPIO128 0x1U // Data Register for this pin
#define GPIO_GPEDAT_GPIO129 0x2U // Data Register for this pin
#define GPIO_GPEDAT_GPIO130 0x4U // Data Register for this pin
#define GPIO_GPEDAT_GPIO131 0x8U // Data Register for this pin
#define GPIO_GPEDAT_GPIO132 0x10U // Data Register for this pin
#define GPIO_GPEDAT_GPIO133 0x20U // Data Register for this pin
#define GPIO_GPEDAT_GPIO134 0x40U // Data Register for this pin
#define GPIO_GPEDAT_GPIO135 0x80U // Data Register for this pin
#define GPIO_GPEDAT_GPIO136 0x100U // Data Register for this pin
#define GPIO_GPEDAT_GPIO137 0x200U // Data Register for this pin
#define GPIO_GPEDAT_GPIO138 0x400U // Data Register for this pin
#define GPIO_GPEDAT_GPIO139 0x800U // Data Register for this pin
#define GPIO_GPEDAT_GPIO140 0x1000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO141 0x2000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO142 0x4000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO143 0x8000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO144 0x10000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO145 0x20000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO146 0x40000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO147 0x80000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO148 0x100000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO149 0x200000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO150 0x400000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO151 0x800000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO152 0x1000000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO153 0x2000000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO154 0x4000000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO155 0x8000000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO156 0x10000000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO157 0x20000000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO158 0x40000000U // Data Register for this pin
#define GPIO_GPEDAT_GPIO159 0x80000000U // Data Register for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPESET register
//
//*************************************************************************************************
#define GPIO_GPESET_GPIO128 0x1U // Output Set bit for this pin
#define GPIO_GPESET_GPIO129 0x2U // Output Set bit for this pin
#define GPIO_GPESET_GPIO130 0x4U // Output Set bit for this pin
#define GPIO_GPESET_GPIO131 0x8U // Output Set bit for this pin
#define GPIO_GPESET_GPIO132 0x10U // Output Set bit for this pin
#define GPIO_GPESET_GPIO133 0x20U // Output Set bit for this pin
#define GPIO_GPESET_GPIO134 0x40U // Output Set bit for this pin
#define GPIO_GPESET_GPIO135 0x80U // Output Set bit for this pin
#define GPIO_GPESET_GPIO136 0x100U // Output Set bit for this pin
#define GPIO_GPESET_GPIO137 0x200U // Output Set bit for this pin
#define GPIO_GPESET_GPIO138 0x400U // Output Set bit for this pin
#define GPIO_GPESET_GPIO139 0x800U // Output Set bit for this pin
#define GPIO_GPESET_GPIO140 0x1000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO141 0x2000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO142 0x4000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO143 0x8000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO144 0x10000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO145 0x20000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO146 0x40000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO147 0x80000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO148 0x100000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO149 0x200000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO150 0x400000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO151 0x800000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO152 0x1000000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO153 0x2000000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO154 0x4000000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO155 0x8000000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO156 0x10000000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO157 0x20000000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO158 0x40000000U // Output Set bit for this pin
#define GPIO_GPESET_GPIO159 0x80000000U // Output Set bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPECLEAR register
//
//*************************************************************************************************
#define GPIO_GPECLEAR_GPIO128 0x1U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO129 0x2U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO130 0x4U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO131 0x8U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO132 0x10U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO133 0x20U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO134 0x40U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO135 0x80U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO136 0x100U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO137 0x200U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO138 0x400U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO139 0x800U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO140 0x1000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO141 0x2000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO142 0x4000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO143 0x8000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO144 0x10000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO145 0x20000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO146 0x40000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO147 0x80000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO148 0x100000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO149 0x200000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO150 0x400000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO151 0x800000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO152 0x1000000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO153 0x2000000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO154 0x4000000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO155 0x8000000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO156 0x10000000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO157 0x20000000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO158 0x40000000U // Output Clear bit for this pin
#define GPIO_GPECLEAR_GPIO159 0x80000000U // Output Clear bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPETOGGLE register
//
//*************************************************************************************************
#define GPIO_GPETOGGLE_GPIO128 0x1U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO129 0x2U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO130 0x4U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO131 0x8U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO132 0x10U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO133 0x20U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO134 0x40U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO135 0x80U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO136 0x100U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO137 0x200U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO138 0x400U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO139 0x800U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO140 0x1000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO141 0x2000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO142 0x4000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO143 0x8000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO144 0x10000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO145 0x20000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO146 0x40000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO147 0x80000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO148 0x100000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO149 0x200000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO150 0x400000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO151 0x800000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO152 0x1000000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO153 0x2000000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO154 0x4000000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO155 0x8000000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO156 0x10000000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO157 0x20000000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO158 0x40000000U // Output Toggle bit for this pin
#define GPIO_GPETOGGLE_GPIO159 0x80000000U // Output Toggle bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPFDAT register
//
//*************************************************************************************************
#define GPIO_GPFDAT_GPIO160 0x1U // Data Register for this pin
#define GPIO_GPFDAT_GPIO161 0x2U // Data Register for this pin
#define GPIO_GPFDAT_GPIO162 0x4U // Data Register for this pin
#define GPIO_GPFDAT_GPIO163 0x8U // Data Register for this pin
#define GPIO_GPFDAT_GPIO164 0x10U // Data Register for this pin
#define GPIO_GPFDAT_GPIO165 0x20U // Data Register for this pin
#define GPIO_GPFDAT_GPIO166 0x40U // Data Register for this pin
#define GPIO_GPFDAT_GPIO167 0x80U // Data Register for this pin
#define GPIO_GPFDAT_GPIO168 0x100U // Data Register for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPFSET register
//
//*************************************************************************************************
#define GPIO_GPFSET_GPIO160 0x1U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO161 0x2U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO162 0x4U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO163 0x8U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO164 0x10U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO165 0x20U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO166 0x40U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO167 0x80U // Output Set bit for this pin
#define GPIO_GPFSET_GPIO168 0x100U // Output Set bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPFCLEAR register
//
//*************************************************************************************************
#define GPIO_GPFCLEAR_GPIO160 0x1U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO161 0x2U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO162 0x4U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO163 0x8U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO164 0x10U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO165 0x20U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO166 0x40U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO167 0x80U // Output Clear bit for this pin
#define GPIO_GPFCLEAR_GPIO168 0x100U // Output Clear bit for this pin
//*************************************************************************************************
//
// The following are defines for the bit fields in the GPFTOGGLE register
//
//*************************************************************************************************
#define GPIO_GPFTOGGLE_GPIO160 0x1U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO161 0x2U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO162 0x4U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO163 0x8U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO164 0x10U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO165 0x20U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO166 0x40U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO167 0x80U // Output Toggle bit for this pin
#define GPIO_GPFTOGGLE_GPIO168 0x100U // Output Toggle bit for this pin
#endif
@@ -0,0 +1,431 @@
//###########################################################################
//
// FILE: hw_i2c.h
//
// TITLE: Definitions for the I2C registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_I2C_H
#define HW_I2C_H
//*************************************************************************************************
//
// The following are defines for the I2C register offsets
//
//*************************************************************************************************
#define I2C_O_MSA 0x0U // I2C Master Slave Address
#define I2C_O_MCS 0x4U // I2C Master Control/Status
#define I2C_O_MDR 0x8U // I2C Master Data
#define I2C_O_MTPR 0xCU // I2C Master Timer Period
#define I2C_O_MIMR 0x10U // I2C Master Interrupt Mask
#define I2C_O_MRIS 0x14U // I2C Master Raw Interrupt Status
#define I2C_O_MMIS 0x18U // I2C Master Masked Interrupt Status
#define I2C_O_MICR 0x1CU // I2C Master Interrupt Clear
#define I2C_O_MCR 0x20U // I2C Master Configuration
#define I2C_O_MCLKOCNT 0x24U // I2C Master Clock Low Timeout Count
#define I2C_O_MBMON 0x2CU // I2C Master Bus Monitor
#define I2C_O_MBLEN 0x30U // I2C Master Burst Length
#define I2C_O_MBCNT 0x34U // I2C Master Burst Count
#define I2C_O_SOAR 0x800U // I2C Slave Own Address
#define I2C_O_SCSR 0x804U // I2C Slave Control/Status
#define I2C_O_SDR 0x808U // I2C Slave Data
#define I2C_O_SIMR 0x80CU // I2C Slave Interrupt Mask
#define I2C_O_SRIS 0x810U // I2C Slave Raw Interrupt Status
#define I2C_O_SMIS 0x814U // I2C Slave Masked Interrupt Status
#define I2C_O_SICR 0x818U // I2C Slave Interrupt Clear
#define I2C_O_SOAR2 0x81CU // I2C Slave Own Address 2
#define I2C_O_SACKCTL 0x820U // I2C Slave ACK Control
#define I2C_O_FIFODATARX 0xF00U // I2C FIFO Data RX
#define I2C_O_FIFOCTL 0xF04U // I2C FIFO Control
#define I2C_O_FIFOSTATUS 0xF08U // I2C FIFO Status
#define I2C_O_PP 0xFC0U // I2C Peripheral Properties
#define I2C_O_PC 0xFC4U // I2C Peripheral Configuration
#define I2C_O_MCS_WRITE 0x4U // I2C Master Control/Status
#define I2C_O_SCSR_WRITE 0x804U // I2C Slave Control/Status
#define I2C_O_FIFODATATX 0xF00U // I2C FIFO Data TX
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMSA register
//
//*************************************************************************************************
#define I2C_MSA_RS 0x1U // Receive/Send
#define I2C_MSA_SA_S 1U
#define I2C_MSA_SA_M 0xFEU // I2C Slave Address
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMCS register
//
//*************************************************************************************************
#define I2C_MCS_BUSY 0x1U // I2C Busy
#define I2C_MCS_ERROR 0x2U // Error
#define I2C_MCS_ADRACK 0x4U // Acknowledge Address
#define I2C_MCS_DATACK 0x8U // Acknowledge Data
#define I2C_MCS_ARBLST 0x10U // Arbitration Lost
#define I2C_MCS_IDLE 0x20U // I2C Idle
#define I2C_MCS_BUSBSY 0x40U // Bus Busy
#define I2C_MCS_CLKTO 0x80U // Clock Timeout Error
#define I2C_MCS_ACTDMATX 0x40000000U // DMA TX Active Status
#define I2C_MCS_ACTDMARX 0x80000000U // DMA RX Active Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMDR register
//
//*************************************************************************************************
#define I2C_MDR_DATA_S 0U
#define I2C_MDR_DATA_M 0xFFU // Data transmitted/received
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMTPR register
//
//*************************************************************************************************
#define I2C_MTPR_TPR_S 0U
#define I2C_MTPR_TPR_M 0x7FU // Timer Period
#define I2C_MTPR_HS 0x80U // High-Speed Enable
#define I2C_MTPR_PULSEL_S 16U
#define I2C_MTPR_PULSEL_M 0x70000U // Glitch Suppression Pulse Width
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMIMR register
//
//*************************************************************************************************
#define I2C_MIMR_IM 0x1U // Master Interrupt Mask
#define I2C_MIMR_CLKIM 0x2U // Clock Timeout Interrupt Mask
#define I2C_MIMR_DMARXIM 0x4U // Receive DMA Interrupt Mask
#define I2C_MIMR_DMATXIM 0x8U // Transmit DMA Interrupt Mask
#define I2C_MIMR_NACKIM 0x10U // Address/Data NACK Interrupt Mask
#define I2C_MIMR_STARTIM 0x20U // START Detection Interrupt Mask
#define I2C_MIMR_STOPIM 0x40U // STOP Detection Interrupt Mask
#define I2C_MIMR_ARBLOSTIM 0x80U // Arbitration Lost Interrupt Mask
#define I2C_MIMR_TXIM 0x100U // Transmit FIFO Request Interrupt Mask
#define I2C_MIMR_RXIM 0x200U // Receive FIFO Request Interrupt Mask
#define I2C_MIMR_TXFEIM 0x400U // Transmit FIFO Empty Interrupt Mask
#define I2C_MIMR_RXFFIM 0x800U // Receive FIFO Full Interrupt Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMRIS register
//
//*************************************************************************************************
#define I2C_MRIS_RIS 0x1U // Master Raw Interrupt Status
#define I2C_MRIS_CLKRIS 0x2U // Clock Timeout Raw Interrupt Status
#define I2C_MRIS_DMARXRIS 0x4U // Receive DMA Raw Interrupt Status
#define I2C_MRIS_DMATXRIS 0x8U // Transmit DMA Raw Interrupt Status
#define I2C_MRIS_NACKRIS 0x10U // Address/Data NACK Raw Interrupt Status
#define I2C_MRIS_STARTRIS 0x20U // START Detection Raw Interrupt Status
#define I2C_MRIS_STOPRIS 0x40U // STOP Detection Raw Interrupt Status
#define I2C_MRIS_ARBLOSTRIS 0x80U // Arbitration Lost Raw Interrupt Status
#define I2C_MRIS_TXRIS 0x100U // Transmit Request Raw Interrupt Status
#define I2C_MRIS_RXRIS 0x200U // Receive FIFO Request Raw Interrupt Status
#define I2C_MRIS_TXFERIS 0x400U // Transmit FIFO Empty Raw Interrupt Status
#define I2C_MRIS_RXFFRIS 0x800U // Receive FIFO Full Raw Interrupt Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMMIS register
//
//*************************************************************************************************
#define I2C_MMIS_MIS 0x1U // Masked Interrupt Status
#define I2C_MMIS_CLKMIS 0x2U // Clock Timeout Masked Interrupt Status
#define I2C_MMIS_DMARXMIS 0x4U // Receive DMA Interrupt Status
#define I2C_MMIS_DMATXMIS 0x8U // Transmit DMA Interrupt Status
#define I2C_MMIS_NACKMIS 0x10U // Address/Data NACK Interrupt Mask
#define I2C_MMIS_STARTMIS 0x20U // START Detection Interrupt Mask
#define I2C_MMIS_STOPMIS 0x40U // STOP Detection Interrupt Mask
#define I2C_MMIS_ARBLOSTMIS 0x80U // Arbitration Lost Interrupt Mask
#define I2C_MMIS_TXMIS 0x100U // Transmit Request Interrupt Mask
#define I2C_MMIS_RXMIS 0x200U // Receive FIFO Request Interrupt Mask
#define I2C_MMIS_TXFEMIS 0x400U // Transmit FIFO Empty Interrupt Mask
#define I2C_MMIS_RXFFMIS 0x800U // Receive FIFO Full Interrupt Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMICR register
//
//*************************************************************************************************
#define I2C_MICR_IC 0x1U // Master Interrupt Clear
#define I2C_MICR_CLKIC 0x2U // Clock Timeout Interrupt Clear
#define I2C_MICR_DMARXIC 0x4U // Receive DMA Interrupt Clear
#define I2C_MICR_DMATXIC 0x8U // Transmit DMA Interrupt Clear
#define I2C_MICR_NACKIC 0x10U // Address/Data NACK Interrupt Clear
#define I2C_MICR_STARTIC 0x20U // START Detection Interrupt Clear
#define I2C_MICR_STOPIC 0x40U // STOP Detection Interrupt Clear
#define I2C_MICR_ARBLOSTIC 0x80U // Arbitration Lost Interrupt Clear
#define I2C_MICR_TXIC 0x100U // Transmit FIFO Request Interrupt Clear
#define I2C_MICR_RXIC 0x200U // Receive FIFO Request Interrupt Clear
#define I2C_MICR_TXFEIC 0x400U // Transmit FIFO Empty Interrupt Clear
#define I2C_MICR_RXFFIC 0x800U // Receive FIFO Full Interrupt Clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMCR register
//
//*************************************************************************************************
#define I2C_MCR_LPBK 0x1U // I2C Loopback
#define I2C_MCR_MFE 0x10U // I2C Master Function Enable
#define I2C_MCR_SFE 0x20U // I2C Slave Function Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMCLKOCNT register
//
//*************************************************************************************************
#define I2C_MCLKOCNT_CNTL_S 0U
#define I2C_MCLKOCNT_CNTL_M 0xFFU // I2C Master Count
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMBMON register
//
//*************************************************************************************************
#define I2C_MBMON_SCL 0x1U // I2C SCL Status
#define I2C_MBMON_SDA 0x2U // I2C SDA Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMBLEN register
//
//*************************************************************************************************
#define I2C_MBLEN_CNTL_S 0U
#define I2C_MBLEN_CNTL_M 0xFFU // I2C Burst Length
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMBCNT register
//
//*************************************************************************************************
#define I2C_MBCNT_CNTL_S 0U
#define I2C_MBCNT_CNTL_M 0xFFU // I2C Master Burst Count
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSOAR register
//
//*************************************************************************************************
#define I2C_SOAR_OAR_S 0U
#define I2C_SOAR_OAR_M 0x7FU // I2C Slave Own Address
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSCSR register
//
//*************************************************************************************************
#define I2C_SCSR_RREQ 0x1U // Receive Request
#define I2C_SCSR_TREQ 0x2U // Transmit Request
#define I2C_SCSR_FBR 0x4U // First Byte Received
#define I2C_SCSR_OAR2SEL 0x8U // OAR2 Address Matched
#define I2C_SCSR_QCMDST 0x10U // Quick Command Status
#define I2C_SCSR_QCMDRW 0x20U // Quick Command Read / Write
#define I2C_SCSR_ACTDMATX 0x40000000U // DMA TX Active Status
#define I2C_SCSR_ACTDMARX 0x80000000U // DMA RX Active Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSDR register
//
//*************************************************************************************************
#define I2C_SDR_DATA_S 0U
#define I2C_SDR_DATA_M 0xFFU // Data for Transfer
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSIMR register
//
//*************************************************************************************************
#define I2C_SIMR_DATAIM 0x1U // Data Interrupt Mask
#define I2C_SIMR_STARTIM 0x2U // Start Condition Interrupt Mask
#define I2C_SIMR_STOPIM 0x4U // Stop Condition Interrupt Mask
#define I2C_SIMR_DMARXIM 0x8U // Receive DMA Interrupt Mask
#define I2C_SIMR_DMATXIM 0x10U // Transmit DMA Interrupt Mask
#define I2C_SIMR_TXIM 0x20U // Transmit FIFO Request Interrupt Mask
#define I2C_SIMR_RXIM 0x40U // Receive FIFO Request Interrupt Mask
#define I2C_SIMR_TXFEIM 0x80U // Transmit FIFO Empty Interrupt Mask
#define I2C_SIMR_RXFFIM 0x100U // Receive FIFO Full Interrupt Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSRIS register
//
//*************************************************************************************************
#define I2C_SRIS_DATARIS 0x1U // Data Raw Interrupt Status
#define I2C_SRIS_STARTRIS 0x2U // Start Condition Raw Interrupt Status
#define I2C_SRIS_STOPRIS 0x4U // Stop Condition Raw Interrupt Status
#define I2C_SRIS_DMARXRIS 0x8U // Receive DMA Raw Interrupt Status
#define I2C_SRIS_DMATXRIS 0x10U // Transmit DMA Raw Interrupt Status
#define I2C_SRIS_TXRIS 0x20U // Transmit Request Raw Interrupt Status
#define I2C_SRIS_RXRIS 0x40U // Receive FIFO Request Raw Interrupt Status
#define I2C_SRIS_TXFERIS 0x80U // Transmit FIFO Empty Raw Interrupt Status
#define I2C_SRIS_RXFFRIS 0x100U // Receive FIFO Full Raw Interrupt Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSMIS register
//
//*************************************************************************************************
#define I2C_SMIS_DATAMIS 0x1U // Data Masked Interrupt Status
#define I2C_SMIS_STARTMIS 0x2U // Start Condition Masked Interrupt Status
#define I2C_SMIS_STOPMIS 0x4U // Stop Condition Masked Interrupt Status
#define I2C_SMIS_DMARXMIS 0x8U // Receive DMA Masked Interrupt Status
#define I2C_SMIS_DMATXMIS 0x10U // Transmit DMA Masked Interrupt Status
#define I2C_SMIS_TXMIS 0x20U // Transmit FIFO Request Interrupt Mask
#define I2C_SMIS_RXMIS 0x40U // Receive FIFO Request Interrupt Mask
#define I2C_SMIS_TXFEMIS 0x80U // Transmit FIFO Empty Interrupt Mask
#define I2C_SMIS_RXFFMIS 0x100U // Receive FIFO Full Interrupt Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSICR register
//
//*************************************************************************************************
#define I2C_SICR_DATAIC 0x1U // Data Interrupt Clear
#define I2C_SICR_STARTIC 0x2U // Start Condition Interrupt Clear
#define I2C_SICR_STOPIC 0x4U // Stop Condition Interrupt Clear
#define I2C_SICR_DMARXIC 0x8U // Receive DMA Interrupt Clear
#define I2C_SICR_DMATXIC 0x10U // Transmit DMA Interrupt Clear
#define I2C_SICR_TXIC 0x20U // Transmit Request Interrupt Mask
#define I2C_SICR_RXIC 0x40U // Receive Request Interrupt Mask
#define I2C_SICR_TXFEIC 0x80U // Transmit FIFO Empty Interrupt Mask
#define I2C_SICR_RXFFIC 0x100U // Receive FIFO Full Interrupt Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSOAR2 register
//
//*************************************************************************************************
#define I2C_SOAR2_OAR2_S 0U
#define I2C_SOAR2_OAR2_M 0x7FU // I2C Slave Own Address 2
#define I2C_SOAR2_OAR2EN 0x80U // I2C Slave Own Address 2 Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSACKCTL register
//
//*************************************************************************************************
#define I2C_SACKCTL_ACKOEN 0x1U // I2C Slave ACK Override Enable
#define I2C_SACKCTL_ACKOVAL 0x2U // I2C Slave ACK Override Value
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CFIFODATARX register
//
//*************************************************************************************************
#define I2C_FIFODATARX_DATA_S 0U
#define I2C_FIFODATARX_DATA_M 0xFFU // I2C RX FIFO Read Data Byte
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CFIFOCTL register
//
//*************************************************************************************************
#define I2C_FIFOCTL_TXTRIG_S 0U
#define I2C_FIFOCTL_TXTRIG_M 0x7U // TX FIFO Trigger
#define I2C_FIFOCTL_DMATXENA 0x2000U // DMA TX Channel Enable
#define I2C_FIFOCTL_TXFLUSH 0x4000U // TX FIFO Flush
#define I2C_FIFOCTL_TXASGNMT 0x8000U // TX Control Assignment
#define I2C_FIFOCTL_RXTRIG_S 16U
#define I2C_FIFOCTL_RXTRIG_M 0x70000U // RX FIFO Trigger
#define I2C_FIFOCTL_DMARXENA 0x20000000U // DMA RX Channel Enable
#define I2C_FIFOCTL_RXFLUSH 0x40000000U // RX FIFO Flush
#define I2C_FIFOCTL_RXASGNMT 0x80000000U // RX Control Assignment
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CFIFOSTATUS register
//
//*************************************************************************************************
#define I2C_FIFOSTATUS_TXFE 0x1U // TX FIFO Empty
#define I2C_FIFOSTATUS_TXFF 0x2U // TX FIFO Full
#define I2C_FIFOSTATUS_TXBLWTRIG 0x4U // TX FIFO Below Trigger Level
#define I2C_FIFOSTATUS_RXFE 0x10000U // RX FIFO Empty
#define I2C_FIFOSTATUS_RXFF 0x20000U // RX FIFO Full
#define I2C_FIFOSTATUS_RXABVTRIG 0x40000U // RX FIFO Above Trigger Level
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CPP register
//
//*************************************************************************************************
#define I2C_PP_HS 0x1U // High-Speed Capable
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CPC register
//
//*************************************************************************************************
#define I2C_PC_HS 0x1U // High-Speed Capable
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CMCS_WRITE register
//
//*************************************************************************************************
#define I2C_MCS_WRITE_RUN 0x1U // I2C Master Enable
#define I2C_MCS_WRITE_START 0x2U // Generate START
#define I2C_MCS_WRITE_STOP 0x4U // Generate STOP
#define I2C_MCS_WRITE_ACK 0x8U // Data Acknowledge Enable
#define I2C_MCS_WRITE_HS 0x10U // High-Speed Enable
#define I2C_MCS_WRITE_QCMD 0x20U // Quick Command
#define I2C_MCS_WRITE_BURST 0x40U // Burst Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CSCSR_WRITE register
//
//*************************************************************************************************
#define I2C_SCSR_WRITE_DA 0x1U // Device Active
#define I2C_SCSR_WRITE_TXFIFO 0x2U // TX FIFO Enable
#define I2C_SCSR_WRITE_RXFIFO 0x4U // RX FIFO Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the I2CFIFODATATX register
//
//*************************************************************************************************
#define I2C_FIFODATATX_DATA_S 0U
#define I2C_FIFODATATX_DATA_M 0xFFU // I2C TX FIFO Write Data Byte
#endif
@@ -0,0 +1,123 @@
//###########################################################################
//
// FILE: hw_ints.h
//
// TITLE: Macros that define the interrupt assignment.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_INTS_H
#define HW_INTS_H
//*****************************************************************************
// The following are defines for the fault assignments.
//*****************************************************************************
#define FAULT_NMI 2U // NMI
#define FAULT_HARD 3U // HardFault
#define FAULT_MPU 4U // MemManage
#define FAULT_BUS 5U // BusFault
#define FAULT_USAGE 6U // UsageFault
#define FAULT_SVCALL 11U // SVCall
#define FAULT_DEBUG 12U // Debug Monitor
#define FAULT_PENDSV 14U // PendSV
#define FAULT_SYSTICK 15U // SysTick
//*****************************************************************************
// The following are defines for the interrupt assignments.
//*****************************************************************************
#define INT_MCANSS_0 16U // MCANSS_0 Interrupt
#define INT_MCANSS_1 17U // MCANSS_1 Interrupt
#define INT_MCANSS_WAKE_AND_TS_PLS 18U // MCANSS_WAKE_AND_TS_PLS Interrupt
#define INT_MCANSS_ECC_CORR_PLS 19U // MCANSS_ECC_CORR_PLS Interrupt
#define INT_ECAT 21U // ECAT Interrupt
#define INT_ECAT_SYNC0 22U // ECAT_SYNC0 Interrupt
#define INT_ECAT_SYNC1 23U // ECAT_SYNC1 Interrupt
#define INT_ECAT_RST 24U // ECAT_RST Interrupt
#define INT_CANA0 25U // CANA0 Interrupt
#define INT_CANA1 26U // CANA1 Interrupt
#define INT_CANB0 27U // CANB0 Interrupt
#define INT_CANB1 28U // CANB1 Interrupt
#define INT_EMAC 29U // EMAC Interrupt
#define INT_EMAC_TX0 30U // EMAC_TX0 Interrupt
#define INT_EMAC_TX1 31U // EMAC_TX1 Interrupt
#define INT_EMAC_RX0 32U // EMAC_RX0 Interrupt
#define INT_EMAC_RX1 33U // EMAC_RX1 Interrupt
#define INT_UART0 34U // UART0 Interrupt
#define INT_SSI0 36U // SSI0 Interrupt
#define INT_I2C0 38U // I2C0 Interrupt
#define INT_USB0 40U // USB Interrupt
#define INT_UDMA_SW 41U // UDMA_SW Interrupt
#define INT_UDMA_ERR 42U // UDMA_ERR Interrupt
#define INT_CPU1TOCMIPC0 45U // CPU1TOCMIPC0 Interrupt
#define INT_CPU1TOCMIPC1 46U // CPU1TOCMIPC1 Interrupt
#define INT_CPU1TOCMIPC2 47U // CPU1TOCMIPC2 Interrupt
#define INT_CPU1TOCMIPC3 48U // CPU1TOCMIPC3 Interrupt
#define INT_CPU1TOCMIPC4 49U // CPU1TOCMIPC4 Interrupt
#define INT_CPU1TOCMIPC5 50U // CPU1TOCMIPC5 Interrupt
#define INT_CPU1TOCMIPC6 51U // CPU1TOCMIPC6 Interrupt
#define INT_CPU1TOCMIPC7 52U // CPU1TOCMIPC7 Interrupt
#define INT_CPU2TOCMIPC0 53U // CPU2TOCMIPC0 Interrupt
#define INT_CPU2TOCMIPC1 54U // CPU2TOCMIPC1 Interrupt
#define INT_CPU2TOCMIPC2 55U // CPU2TOCMIPC2 Interrupt
#define INT_CPU2TOCMIPC3 56U // CPU2TOCMIPC3 Interrupt
#define INT_CPU2TOCMIPC4 57U // CPU2TOCMIPC4 Interrupt
#define INT_CPU2TOCMIPC5 58U // CPU2TOCMIPC5 Interrupt
#define INT_CPU2TOCMIPC6 59U // CPU2TOCMIPC6 Interrupt
#define INT_CPU2TOCMIPC7 60U // CPU2TOCMIPC7 Interrupt
#define INT_FMC 61U // FMC Interrupt
#define INT_FMC_CORR_ERR 62U // FMC_CORR_ERR Interrupt
#define INT_AES 63U // AES Interrupt
#define INT_TIMER0 64U // TIMER0 Interrupt
#define INT_TIMER1 65U // TIMER1 Interrupt
#define INT_TIMER2 66U // TIMER2 Interrupt
#define INT_CMRAM_TESTERROR_LOG 67U // CMRAM_TESTERROR_LOG Interrupt
//*****************************************************************************
// The following are defines for the total number of interrupts.
//*****************************************************************************
#define NUM_INTERRUPTS 80U
//*****************************************************************************
// The following are defines for the total number of priority levels.
//*****************************************************************************
#define NUM_PRIORITY 8U
#define NUM_PRIORITY_BITS 3U
#endif // HW_INTS_H
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,449 @@
//###########################################################################
//
// FILE: hw_memcfg.h
//
// TITLE: Definitions for the MEMCFG registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_MEMCFG_H
#define HW_MEMCFG_H
//*************************************************************************************************
//
// The following are defines for the MEMCFG register offsets
//
//*************************************************************************************************
#define MEMCFG_O_CXLOCK 0x0U // C RAM Config Lock Register
#define MEMCFG_O_CXTEST 0x4U // C RAM TEST Register
#define MEMCFG_O_CXINIT 0x8U // C RAM Init Register
#define MEMCFG_O_CXINITDONE 0xCU // C RAM Initialization Status Register
#define MEMCFG_O_CMMSGXLOCK 0x20U // CM Messae RAM Config Lock Register
#define MEMCFG_O_CMMSGXTEST 0x24U // CM Messae RAM TEST Register
#define MEMCFG_O_CMMSGXINIT 0x28U // CM Messae RAM Init Register
#define MEMCFG_O_CMMSGXINITDONE 0x2CU // CM Messae RAM Initialization Status Register
#define MEMCFG_O_SXGROUP1_LOCK 0x40U // Group1 S and E RAM Config Lock Register
#define MEMCFG_O_SXGROUP1_TEST 0x44U // Group1 S and E RAM TEST Register
#define MEMCFG_O_SXGROUP1_INIT 0x48U // Group1 S and E RAM Init Register
#define MEMCFG_O_SXGROUP1_INITDONE 0x4CU // Group1 S and E RAM Initialization Status
// Register
#define MEMCFG_O_ROM_LOCK 0x80U // ROM Config Lock Register
#define MEMCFG_O_ROM_TEST 0x84U // ROM TEST Register
#define MEMCFG_O_ROM_FORCE_ERROR 0x88U // ROM Force Error register
#define MEMCFG_O_PERI_MEM_TEST_LOCK 0xA0U // Peripheral Memory Test Lock Register
#define MEMCFG_O_PERI_MEM_TEST_CONTROL 0xA4U // Peripheral Memory Test control Register
#define MEMCFG_O_UCERRFLG 0x0U // Uncorrectable Error Flag Register
#define MEMCFG_O_UCERRSET 0x4U // Uncorrectable Error Flag Set Register
#define MEMCFG_O_UCERRCLR 0x8U // Uncorrectable Error Flag Clear Register
#define MEMCFG_O_UCM4EADDR 0xCU // Uncorrectable M4 Error Address
#define MEMCFG_O_UCEMACEADDR 0x10U // Uncorrectable EMAC Error Address
#define MEMCFG_O_UCUDMAEADDR 0x14U // Uncorrectable uDMA Error Address
#define MEMCFG_O_UCETHERCATMEMREADDR 0x18U // Uncorrectable EtherCAT IP RAM Read Error Address
#define MEMCFG_O_UCEMACMEMREADDR 0x1CU // Uncorrectable EMAC IP RAM Read Error Address
#define MEMCFG_O_BUSFAULTFLG 0x50U // BusFault Flag register
#define MEMCFG_O_BUSFAULTCLR 0x54U // BusFault Flag clear register
#define MEMCFG_O_M4BUSFAULTADDR 0x58U // M4 busfault address
#define MEMCFG_O_UDMABUSFAULTADDR 0x5CU // uDMA busfault address
#define MEMCFG_O_EMACBUSFAULTADDR 0x60U // EMAC busfault address
#define MEMCFG_O_CERRFLG 0x80U // Correctable Error Flag Register
#define MEMCFG_O_CERRSET 0x84U // Correctable Error Flag Set Register
#define MEMCFG_O_CERRCLR 0x88U // Correctable Error Flag Clear Register
#define MEMCFG_O_CM4EADDR 0x8CU // Correctable M4 Error Address
#define MEMCFG_O_CEMACEADDR 0x90U // Correctable EMAC Error Address
#define MEMCFG_O_CUDMAEADDR 0x94U // Correctable uDMA Error Address
#define MEMCFG_O_CERRCNT 0xC0U // Correctable Error Count Register
#define MEMCFG_O_CERRTHRES 0xC4U // Correctable Error Threshold Value Register
#define MEMCFG_O_CEINTFLG 0xC8U // Correctable Error Interrupt Flag Status Register
#define MEMCFG_O_CEINTSET 0xCCU // Correctable Error Interrupt Flag Set Register
#define MEMCFG_O_CEINTCLR 0xD0U // Correctable Error Interrupt Flag Clear Register
#define MEMCFG_O_CEINTEN 0xD4U // Correctable Error Interrupt Enable Register
#define MEMCFG_O_DIAGERRFLG 0x0U // Error Flag Register
#define MEMCFG_O_DIAGERRCLR 0x8U // Error Flag Clear Register
#define MEMCFG_O_DIAGERRADDR 0xCU // Read Error Address
//*************************************************************************************************
//
// The following are defines for the bit fields in the CxLOCK register
//
//*************************************************************************************************
#define MEMCFG_CXLOCK_LOCK_C0 0x1U // C0 RAM Lock bits
#define MEMCFG_CXLOCK_LOCK_C1 0x2U // C1 RAM Lock bits
//*************************************************************************************************
//
// The following are defines for the bit fields in the CxTEST register
//
//*************************************************************************************************
#define MEMCFG_CXTEST_TEST_C0_S 0U
#define MEMCFG_CXTEST_TEST_C0_M 0x3U // Selects the different modes for C0 RAM
#define MEMCFG_CXTEST_TEST_C1_S 2U
#define MEMCFG_CXTEST_TEST_C1_M 0xCU // Selects the different modes for C1 RAM
//*************************************************************************************************
//
// The following are defines for the bit fields in the CxINIT register
//
//*************************************************************************************************
#define MEMCFG_CXINIT_INIT_C0 0x1U // RAM Initialization control for C0 RAM.
#define MEMCFG_CXINIT_INIT_C1 0x2U // RAM Initialization control for C1 RAM.
//*************************************************************************************************
//
// The following are defines for the bit fields in the CxINITDONE register
//
//*************************************************************************************************
#define MEMCFG_CXINITDONE_INITDONE_C0 0x1U // RAM Initialization status for C0 RAM.
#define MEMCFG_CXINITDONE_INITDONE_C1 0x2U // RAM Initialization status for C1 RAM.
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMMSGxLOCK register
//
//*************************************************************************************************
#define MEMCFG_CMMSGXLOCK_LOCK_CMTOCPU1MSGRAM0 0x1U // Message RAM CMTOCPU1MSGRAM0 Lock bits
#define MEMCFG_CMMSGXLOCK_LOCK_CMTOCPU1MSGRAM1 0x2U // Message RAM CMTOCPU1MSGRAM1 Lock bits
#define MEMCFG_CMMSGXLOCK_LOCK_CMTOCPU2MSGRAM0 0x4U // Message RAM CMTOCPU2MSGRAM0 Lock bits
#define MEMCFG_CMMSGXLOCK_LOCK_CMTOCPU2MSGRAM1 0x8U // Message RAM CMTOCPU2MSGRAM1 Lock bits
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMMSGxTEST register
//
//*************************************************************************************************
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU1MSGRAM0_S 0U
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU1MSGRAM0_M 0x3U // Selects the different modes for
// Message RAM CMTOCPU1MSGRAM0
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU1MSGRAM1_S 2U
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU1MSGRAM1_M 0xCU // Selects the different modes for
// Message RAM CMTOCPU1MSGRAM1
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU2MSGRAM0_S 4U
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU2MSGRAM0_M 0x30U // Selects the different modes for
// Message RAM CMTOCPU2MSGRAM0
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU2MSGRAM1_S 6U
#define MEMCFG_CMMSGXTEST_TEST_CMTOCPU2MSGRAM1_M 0xC0U // Selects the different modes for
// Message RAM CMTOCPU2MSGRAM1
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMMSGxINIT register
//
//*************************************************************************************************
#define MEMCFG_CMMSGXINIT_INIT_CMTOCPU1MSGRAM0 0x1U // RAM Initialization control for Message
// RAM CMTOCPU1MSGRAM0
#define MEMCFG_CMMSGXINIT_INIT_CMTOCPU1MSGRAM1 0x2U // RAM Initialization control for Message
// RAM CMTOCPU1MSGRAM1
#define MEMCFG_CMMSGXINIT_INIT_CMTOCPU2MSGRAM0 0x4U // RAM Initialization control for Message
// RAM CMTOCPU2MSGRAM0
#define MEMCFG_CMMSGXINIT_INIT_CMTOCPU2MSGRAM1 0x8U // RAM Initialization control for Message
// RAM CMTOCPU2MSGRAM1
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMMSGxINITDONE register
//
//*************************************************************************************************
#define MEMCFG_CMMSGXINITDONE_INITDONE_CMTOCPU1MSGRAM0 0x1U // RAM Initialization status for
// Message RAM CMTOCPU1MSGRAM0
#define MEMCFG_CMMSGXINITDONE_INITDONE_CMTOCPU1MSGRAM1 0x2U // RAM Initialization status for
// Message RAM CMTOCPU1MSGRAM1
#define MEMCFG_CMMSGXINITDONE_INITDONE_CMTOCPU2MSGRAM0 0x4U // RAM Initialization status for
// Message RAM CMTOCPU2MSGRAM0
#define MEMCFG_CMMSGXINITDONE_INITDONE_CMTOCPU2MSGRAM1 0x8U // RAM Initialization status for
// Message RAM CMTOCPU2MSGRAM1
//*************************************************************************************************
//
// The following are defines for the bit fields in the SxGROUP1_LOCK register
//
//*************************************************************************************************
#define MEMCFG_SXGROUP1_LOCK_LOCK_S0 0x1U // S0 RAM Lock bits
#define MEMCFG_SXGROUP1_LOCK_LOCK_S1 0x2U // S1 RAM Lock bits
#define MEMCFG_SXGROUP1_LOCK_LOCK_S2 0x4U // S2 RAM Lock bits
#define MEMCFG_SXGROUP1_LOCK_LOCK_S3 0x8U // S3 RAM Lock bits
#define MEMCFG_SXGROUP1_LOCK_LOCK_E0 0x10U // E0 RAM Lock bits
//*************************************************************************************************
//
// The following are defines for the bit fields in the SxGROUP1_TEST register
//
//*************************************************************************************************
#define MEMCFG_SXGROUP1_TEST_TEST_S0_S 0U
#define MEMCFG_SXGROUP1_TEST_TEST_S0_M 0x3U // Selects the different modes for S0 RAM
#define MEMCFG_SXGROUP1_TEST_TEST_S1_S 2U
#define MEMCFG_SXGROUP1_TEST_TEST_S1_M 0xCU // Selects the different modes for S1 RAM
#define MEMCFG_SXGROUP1_TEST_TEST_S2_S 4U
#define MEMCFG_SXGROUP1_TEST_TEST_S2_M 0x30U // Selects the different modes for S2 RAM
#define MEMCFG_SXGROUP1_TEST_TEST_S3_S 6U
#define MEMCFG_SXGROUP1_TEST_TEST_S3_M 0xC0U // Selects the different modes for S3 RAM
#define MEMCFG_SXGROUP1_TEST_TEST_E0_S 8U
#define MEMCFG_SXGROUP1_TEST_TEST_E0_M 0x300U // Selects the different modes for E0 RAM
//*************************************************************************************************
//
// The following are defines for the bit fields in the SxGROUP1_INIT register
//
//*************************************************************************************************
#define MEMCFG_SXGROUP1_INIT_INIT_S0 0x1U // RAM Initialization control for S0 RAM.
#define MEMCFG_SXGROUP1_INIT_INIT_S1 0x2U // RAM Initialization control for S1 RAM.
#define MEMCFG_SXGROUP1_INIT_INIT_S2 0x4U // RAM Initialization control for S2 RAM.
#define MEMCFG_SXGROUP1_INIT_INIT_S3 0x8U // RAM Initialization control for S3 RAM.
#define MEMCFG_SXGROUP1_INIT_INIT_E0 0x10U // RAM Initialization control for E0 RAM.
//*************************************************************************************************
//
// The following are defines for the bit fields in the SxGROUP1_INITDONE register
//
//*************************************************************************************************
#define MEMCFG_SXGROUP1_INITDONE_INITDONE_S0 0x1U // RAM Initialization status for S0 RAM.
#define MEMCFG_SXGROUP1_INITDONE_INITDONE_S1 0x2U // RAM Initialization status for S1 RAM.
#define MEMCFG_SXGROUP1_INITDONE_INITDONE_S2 0x4U // RAM Initialization status for S2 RAM.
#define MEMCFG_SXGROUP1_INITDONE_INITDONE_S3 0x8U // RAM Initialization status for S3 RAM.
#define MEMCFG_SXGROUP1_INITDONE_INITDONE_E0 0x10U // RAM Initialization status for E0 RAM.
//*************************************************************************************************
//
// The following are defines for the bit fields in the ROM_LOCK register
//
//*************************************************************************************************
#define MEMCFG_ROM_LOCK_LOCK_BOOTROM 0x1U // BOOTROM Lock bits
//*************************************************************************************************
//
// The following are defines for the bit fields in the ROM_TEST register
//
//*************************************************************************************************
#define MEMCFG_ROM_TEST_TEST_BOOTROM_S 0U
#define MEMCFG_ROM_TEST_TEST_BOOTROM_M 0x3U // Selects the different modes for BOOTROM
//*************************************************************************************************
//
// The following are defines for the bit fields in the ROM_FORCE_ERROR register
//
//*************************************************************************************************
#define MEMCFG_ROM_FORCE_ERROR_FORCE_BOOTROM_ERROR 0x1U // Force Bootrom Parity Error
//*************************************************************************************************
//
// The following are defines for the bit fields in the PERI_MEM_TEST_LOCK register
//
//*************************************************************************************************
#define MEMCFG_PERI_MEM_TEST_LOCK_LOCK_PERI_MEM_TEST_CONTROL 0x1U // PERI_MEM_TEST_CONTROL Lock
// bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the PERI_MEM_TEST_CONTROL register
//
//*************************************************************************************************
#define MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_TEST_ENABLE 0x1U // EMAC Test mode enable
#define MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_MEM_FORCE_ERROR 0x2U // Force Parity Error on
// EMAC RAM
#define MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_TEST_ENABLE 0x10U // EtherCAT Test mode
// enable
#define MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_MEM_FORCE_ERROR 0x20U // Force Parity Error on
// EtherCAT RAM
//*************************************************************************************************
//
// The following are defines for the bit fields in the UCERRFLG register
//
//*************************************************************************************************
#define MEMCFG_UCERRFLG_M4RDERR 0x1U // M4 Uncorrectable Read Error Flag
#define MEMCFG_UCERRFLG_M4WRERR 0x2U // M4 Uncorrectable Write Error Flag
#define MEMCFG_UCERRFLG_EMACRDERR 0x4U // EMAC Uncorrectable Read Error Flag
#define MEMCFG_UCERRFLG_UDMARDERR 0x10U // uDMA Uncorrectable Read Error Flag
#define MEMCFG_UCERRFLG_UDMAWRERR 0x20U // uDMA Uncorrectable Write Error Flag
#define MEMCFG_UCERRFLG_ETHERCATMEMRDERR 0x40U // EtherCAT IP RAM Uncorrectable Read Error Flag
#define MEMCFG_UCERRFLG_EMACMEMRDERR 0x80U // EMAC IP RAM Uncorrectable Read Error Flag
//*************************************************************************************************
//
// The following are defines for the bit fields in the UCERRSET register
//
//*************************************************************************************************
#define MEMCFG_UCERRSET_M4RDERR 0x1U // M4 Uncorrectable Read Error Flag Set
#define MEMCFG_UCERRSET_M4WRERR 0x2U // M4 Uncorrectable Write Error Flag Set
#define MEMCFG_UCERRSET_EMACRDERR 0x4U // EMAC Uncorrectable Read Error Flag Set
#define MEMCFG_UCERRSET_UDMARDERR 0x10U // uDMA Uncorrectable Read Error Flag Set
#define MEMCFG_UCERRSET_UDMAWRERR 0x20U // uDMA Uncorrectable Write Error Flag Set
#define MEMCFG_UCERRSET_ETHERCATMEMRDERR 0x40U // EtherCAT IP RAM Uncorrectable Read
// Error Flag set
#define MEMCFG_UCERRSET_EMACMEMRDERR 0x80U // EMAC IP RAM Uncorrectable Read Error
// Flag set
#define MEMCFG_UCERRSET_KEY_S 16U
#define MEMCFG_UCERRSET_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the UCERRCLR register
//
//*************************************************************************************************
#define MEMCFG_UCERRCLR_M4RDERR 0x1U // M4 Uncorrectable Read Error Flag Clear
#define MEMCFG_UCERRCLR_M4WRERR 0x2U // M4 Uncorrectable Write Error Flag Clear
#define MEMCFG_UCERRCLR_EMACRDERR 0x4U // EMAC Uncorrectable Read Error Flag
// Clear
#define MEMCFG_UCERRCLR_UDMARDERR 0x10U // uDMA Uncorrectable Read Error Flag
// Clear
#define MEMCFG_UCERRCLR_UDMAWRERR 0x20U // uDMA Uncorrectable Write Error Flag
// Clear
#define MEMCFG_UCERRCLR_ETHERCATMEMRDERR 0x40U // EtherCAT IP RAM Uncorrectable Read
// Error Flag Clear
#define MEMCFG_UCERRCLR_EMACMEMRDERR 0x80U // EMAC IP RAM Uncorrectable Read Error
// Flag Clear
#define MEMCFG_UCERRCLR_KEY_S 16U
#define MEMCFG_UCERRCLR_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the BUSFAULTFLG register
//
//*************************************************************************************************
#define MEMCFG_BUSFAULTFLG_M4BUSFAULT 0x1U // M4 busfault Flag
#define MEMCFG_BUSFAULTFLG_UDMABUSFAULT 0x2U // UDMA busfault Flag
#define MEMCFG_BUSFAULTFLG_EMACBUSFAULT 0x4U // EMAC busfault Flag
//*************************************************************************************************
//
// The following are defines for the bit fields in the BUSFAULTCLR register
//
//*************************************************************************************************
#define MEMCFG_BUSFAULTCLR_M4BUSFAULT 0x1U // M4 busfault Flag Clear
#define MEMCFG_BUSFAULTCLR_UDMABUSFAULT 0x2U // UDMA busfault Flag Clear
#define MEMCFG_BUSFAULTCLR_EMACBUSFAULT 0x4U // EMAC busfault Flag Clear
#define MEMCFG_BUSFAULTCLR_KEY_S 16U
#define MEMCFG_BUSFAULTCLR_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the CERRFLG register
//
//*************************************************************************************************
#define MEMCFG_CERRFLG_M4RDERR 0x1U // M4 Correctable Read Error Flag
#define MEMCFG_CERRFLG_M4WRERR 0x2U // M4 Correctable Write Error Flag
#define MEMCFG_CERRFLG_EMACRDERR 0x4U // EMAC Correctable Read Error Flag
#define MEMCFG_CERRFLG_UDMARDERR 0x10U // uDMA Correctable Read Error Flag
#define MEMCFG_CERRFLG_UDMAWRERR 0x20U // uDMA Correctable Write Error Flag
//*************************************************************************************************
//
// The following are defines for the bit fields in the CERRSET register
//
//*************************************************************************************************
#define MEMCFG_CERRSET_M4RDERR 0x1U // M4 Correctable Read Error Flag Set
#define MEMCFG_CERRSET_M4WRERR 0x2U // M4 Correctable Write Error Flag Set
#define MEMCFG_CERRSET_EMACRDERR 0x4U // EMAC Correctable Read Error Flag Set
#define MEMCFG_CERRSET_UDMARDERR 0x10U // uDMA Correctable Read Error Flag Set
#define MEMCFG_CERRSET_UDMAWRERR 0x20U // uDMA Correctable Write Error Flag Set
#define MEMCFG_CERRSET_KEY_S 16U
#define MEMCFG_CERRSET_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the CERRCLR register
//
//*************************************************************************************************
#define MEMCFG_CERRCLR_M4RDERR 0x1U // M4 Correctable Read Error Flag Clear
#define MEMCFG_CERRCLR_M4WRERR 0x2U // M4 Correctable Write Error Flag Clear
#define MEMCFG_CERRCLR_EMACRDERR 0x4U // EMAC Correctable Read Error Flag Clear
#define MEMCFG_CERRCLR_UDMARDERR 0x10U // uDMA Correctable Read Error Flag Clear
#define MEMCFG_CERRCLR_UDMAWRERR 0x20U // uDMA Correctable Write Error Flag Clear
#define MEMCFG_CERRCLR_KEY_S 16U
#define MEMCFG_CERRCLR_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the CEINTFLG register
//
//*************************************************************************************************
#define MEMCFG_CEINTFLG_CEINTFLAG 0x1U // Total corrected error count exceeded threshold flag.
//*************************************************************************************************
//
// The following are defines for the bit fields in the CEINTSET register
//
//*************************************************************************************************
#define MEMCFG_CEINTSET_CEINTSET 0x1U // Total corrected error count exceeded flag set.
#define MEMCFG_CEINTSET_KEY_S 16U
#define MEMCFG_CEINTSET_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the CEINTCLR register
//
//*************************************************************************************************
#define MEMCFG_CEINTCLR_CEINTCLR 0x1U // M4 Corrected Error Threshold Exceeded Error
// Clear.
#define MEMCFG_CEINTCLR_KEY_S 16U
#define MEMCFG_CEINTCLR_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the CEINTEN register
//
//*************************************************************************************************
#define MEMCFG_CEINTEN_CEINTEN 0x1U // M4 Correctable Error Interrupt Enable.
#define MEMCFG_CEINTEN_KEY_S 16U
#define MEMCFG_CEINTEN_KEY_M 0xFFFF0000U // KEY to allow write access
//*************************************************************************************************
//
// The following are defines for the bit fields in the DIAGERRFLG register
//
//*************************************************************************************************
#define MEMCFG_DIAGERRFLG_UCRDERROR 0x1U // Diagnostics Uncorrectable Read Error Flag
#define MEMCFG_DIAGERRFLG_UCWRERROR 0x2U // Diagnostics Uncorrectable Write Error Flag
#define MEMCFG_DIAGERRFLG_CRDERROR 0x4U // Diagnostics Correctable Read Error Flag
#define MEMCFG_DIAGERRFLG_CWRERROR 0x8U // Diagnostics Correctable Write Error Flag
//*************************************************************************************************
//
// The following are defines for the bit fields in the DIAGERRCLR register
//
//*************************************************************************************************
#define MEMCFG_DIAGERRCLR_UCRDERROR 0x1U // Clear diagnostics uncorrectable Read Error Flag
#define MEMCFG_DIAGERRCLR_UCWRERROR 0x2U // Clear diagnostics uncorrectable Write Error Flag
#define MEMCFG_DIAGERRCLR_CRDERROR 0x4U // Clear diagnostics correctable Read Error Flag
#define MEMCFG_DIAGERRCLR_CWRERROR 0x8U // Clear diagnostics correctable Write Error Flag
#endif
@@ -0,0 +1,107 @@
//###########################################################################
//
// FILE: hw_memmap.h
//
// TITLE: Macros defining the memory map of the C28x.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_MEMMAP_H
#define HW_MEMMAP_H
//*****************************************************************************
//
// The following are defines for the base address of the memories and
// peripherals.
//
//*****************************************************************************
#define C1RAM_BASE 0x1FFFC000U
#define C0RAM_BASE 0x1FFFE000U
#define S0RAM_BASE 0x20000000U
#define S1RAM_BASE 0x20004000U
#define S2RAM_BASE 0x20008000U
#define S3RAM_BASE 0x2000C000U
#define E0RAM_BASE 0x20010000U
#define CPU1TOCMMSGRAM0_BASE 0x20080000U
#define CPU1TOCMMSGRAM1_BASE 0x20080800U
#define CMTOCPU1MSGRAM0_BASE 0x20082000U
#define CMTOCPU1MSGRAM1_BASE 0x20082800U
#define CPU2TOCMMSGRAM0_BASE 0x20084000U
#define CPU2TOCMMSGRAM1_BASE 0x20084800U
#define CMTOCPU2MSGRAM0_BASE 0x20086000U
#define CMTOCPU2MSGRAM1_BASE 0x20086800U
#define SSI0_BASE 0x40008000U
#define UART0_BASE 0x4000C000U
#define I2C0_BASE 0x40020000U
#define GCRC_BASE 0x40040000U
#define AES_BASE 0x4004A000U
#define AESW_BASE 0x4004AC00U
#define USB0_BASE 0x40050000U
#define CANA_BASE 0x40070000U
#define CANB_BASE 0x40074000U
#define MCAN0_BASE 0x40078000U
#define MCAN_SS_BASE 0x4007C400U
#define MCAN_BASE 0x4007C600U
#define MCAN_ERROR_BASE 0x4007C800U
#define WD_BASE 0x40080000U
#define NMI_BASE 0x40081000U
#define GPIODATA_BASE 0x40083000U
#define GPIODATAREAD_BASE 0x40083100U
#define CPUTIMER0_BASE 0x40084000U
#define CPUTIMER1_BASE 0x40084010U
#define CPUTIMER2_BASE 0x40084020U
#define DCSM_Z1_BASE 0x40085000U
#define DCSM_Z2_BASE 0x40085100U
#define DCSMCOMMON_BASE 0x40085180U
#define ESC_SS_BASE 0x400AFC00U
#define ESC_SS_CONFIG_BASE 0x400AFE00U
#define EMAC_BASE 0x400C0000U
#define EMAC_SS_BASE 0x400C2000U
#define DMPU_BASE 0x400CC000U
#define EMPU_BASE 0x400CD000U
#define FLASH0CTRL_BASE 0x400FA000U
#define FLASH0ECC_BASE 0x400FA600U
#define CMSYSCTL_BASE 0x400FC000U
#define IPC_CMTOCPU1_BASE 0x400FD000U
#define FLASHPUMPSEMAPHORE_BASE 0x400FD048U
#define IPC_CMTOCPU2_BASE 0x400FD080U
#define CMMEMCFG_BASE 0x400FE000U
#define CMMEMORYERROR_BASE 0x400FE400U
#define CMMEMORYDIAGERROR_BASE 0x400FE800U
#define UDMA_BASE 0x400FF000U
#define NVIC_BASE 0xE000E000U
#endif
@@ -0,0 +1,143 @@
//###########################################################################
//
// FILE: hw_nmi.h
//
// TITLE: Definitions for the NMI registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_NMI_H
#define HW_NMI_H
//*************************************************************************************************
//
// The following are defines for the NMI register offsets
//
//*************************************************************************************************
#define NMI_O_CMNMICFG 0x0U // CM NMI Configuration Register
#define NMI_O_CMNMIFLG 0x4U // CM NMI Flag Register
#define NMI_O_CMNMIFLGCLR 0x8U // CMNMI Flag Clear Register
#define NMI_O_CMNMIFLGFRC 0xCU // CMNMI Flag Force Register
#define NMI_O_CMNMIWDCNT 0x10U // CMNMI Watchdog Counter Register
#define NMI_O_CMNMIWDPRD 0x14U // CMNMI Watchdog Period Register
#define NMI_O_CMNMISHDWFLG 0x18U // CMNMI Shadow Flag Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMNMICFG register
//
//*************************************************************************************************
#define NMI_CMNMICFG_NMIE 0x1U // Global NMI Enable
#define NMI_CMNMICFG_KEY_S 16U
#define NMI_CMNMICFG_KEY_M 0xFFFF0000U // Key protection
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMNMIFLG register
//
//*************************************************************************************************
#define NMI_CMNMIFLG_NMIINT 0x1U // NMI Interrupt Flag
#define NMI_CMNMIFLG_CLOCKFAIL 0x2U // Clock Fail Interrupt Flag
#define NMI_CMNMIFLG_MEMUNCERR 0x4U // RAM, ROM Uncorrectable Error NMI Flag
#define NMI_CMNMIFLG_FLUNCERR 0x8U // Flash Uncorrectable Error NMI Flag
#define NMI_CMNMIFLG_MCANUNCERR 0x10U // MCAN Uncorrectable Error NMI Flag
#define NMI_CMNMIFLG_WWDNMI 0x20U // CM WWD NMI flag
#define NMI_CMNMIFLG_ECATNMI 0x40U // NMI from EtherCAT reset out
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMNMIFLGCLR register
//
//*************************************************************************************************
#define NMI_CMNMIFLGCLR_NMIINT 0x1U // NMIINT Flag Clear
#define NMI_CMNMIFLGCLR_CLOCKFAIL 0x2U // CLOCKFAIL Flag Clear
#define NMI_CMNMIFLGCLR_MEMUNCERR 0x4U // MEMUNCERR Flag Clear
#define NMI_CMNMIFLGCLR_FLUNCERR 0x8U // FLUNCERR Flag Clear
#define NMI_CMNMIFLGCLR_MCANUNCERR 0x10U // MCANUNCERR Flag Clear
#define NMI_CMNMIFLGCLR_WWDNMI 0x20U // WWDNMI Flag Clear
#define NMI_CMNMIFLGCLR_ECATNMI 0x40U // ECATNMI Flag Clear
#define NMI_CMNMIFLGCLR_KEY_S 16U
#define NMI_CMNMIFLGCLR_KEY_M 0xFFFF0000U // Key protection
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMNMIFLGFRC register
//
//*************************************************************************************************
#define NMI_CMNMIFLGFRC_CLOCKFAIL 0x2U // CLOCKFAIL Flag Force
#define NMI_CMNMIFLGFRC_MEMUNCERR 0x4U // MEMUNCERR Flag Force
#define NMI_CMNMIFLGFRC_FLUNCERR 0x8U // FLUNCERR Flag Force
#define NMI_CMNMIFLGFRC_MCANUNCERR 0x10U // MCANUNCERR Flag Force
#define NMI_CMNMIFLGFRC_WWDNMI 0x20U // WWDNMI Flag Force
#define NMI_CMNMIFLGFRC_ECATNMI 0x40U // ECATNMI Flag Force
#define NMI_CMNMIFLGFRC_KEY_S 16U
#define NMI_CMNMIFLGFRC_KEY_M 0xFFFF0000U // Key protection
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMNMIWDCNT register
//
//*************************************************************************************************
#define NMI_CMNMIWDCNT_NMIWDCNT_S 0U
#define NMI_CMNMIWDCNT_NMIWDCNT_M 0xFFFFU // NMI Watchdog Counter
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMNMIWDPRD register
//
//*************************************************************************************************
#define NMI_CMNMIWDPRD_NMIWDPRD_S 0U
#define NMI_CMNMIWDPRD_NMIWDPRD_M 0xFFFFU // NMI Watchdog Period
#define NMI_CMNMIWDPRD_KEY_S 16U
#define NMI_CMNMIWDPRD_KEY_M 0xFFFF0000U // Key protection
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMNMISHDWFLG register
//
//*************************************************************************************************
#define NMI_CMNMISHDWFLG_CLOCKFAIL 0x2U // CLOCKFAIL Shadow flag
#define NMI_CMNMISHDWFLG_MEMUNCERR 0x4U // MEMUNCERR Shadow flag
#define NMI_CMNMISHDWFLG_FLUNCERR 0x8U // FLUNCERR Shadow flag
#define NMI_CMNMISHDWFLG_MCANUNCERR 0x10U // MCANUNCERR Shadow flag
#define NMI_CMNMISHDWFLG_WWDNMI 0x20U // WWDNMI Shadow flag
#define NMI_CMNMISHDWFLG_ECATNMI 0x40U // ECATNMI Shadow flag
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,63 @@
//###########################################################################
//
// FILE: hw_otp.h
//
// TITLE: Definitions for the OTP registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_OTP_H
#define HW_OTP_H
//*************************************************************************************************
//
// The following are defines for the OTP register offsets
//
//*************************************************************************************************
#define OTP_O_UID_PSRAND0 0x0U // UID Psuedo-random 160 bit number
#define OTP_O_UID_PSRAND1 0x2U // UID Psuedo-random 160 bit number
#define OTP_O_UID_PSRAND2 0x4U // UID Psuedo-random 160 bit number
#define OTP_O_UID_PSRAND3 0x6U // UID Psuedo-random 160 bit number
#define OTP_O_UID_PSRAND4 0x8U // UID Psuedo-random 160 bit number
#define OTP_O_UID_PSRAND5 0xAU // UID Psuedo-random 160 bit number
#define OTP_O_UID_UNIQUE 0xCU // UID UID Unique 32 bit number
#define OTP_O_UID_CHECKSUM 0xEU // UID Checksum
#endif
@@ -0,0 +1,307 @@
//###########################################################################
//
// FILE: hw_ssi.h
//
// TITLE: Definitions for the SSI registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_SSI_H
#define HW_SSI_H
//*************************************************************************************************
//
// The following are defines for the SSI register offsets
//
//*************************************************************************************************
#define SSI_O_CR0 0x0U // SSI Control 0
#define SSI_O_CR1 0x4U // SSI Control 1
#define SSI_O_DR 0x8U // SSI Data
#define SSI_O_SR 0xCU // SSI Status
#define SSI_O_CPSR 0x10U // SSI Clock Prescale
#define SSI_O_IM 0x14U // SSI Interrupt Mask
#define SSI_O_RIS 0x18U // SSI Raw Interrupt Status
#define SSI_O_MIS 0x1CU // SSI Masked Interrupt Status
#define SSI_O_ICR 0x20U // SSI Interrupt Clear
#define SSI_O_DMACTL 0x24U // SSI DMA Control
#define SSI_O_PV 0xFB0U // SSI Peripheral Version
#define SSI_O_PP 0xFC0U // SSI Peripheral Properties
#define SSI_O_PERIPHID4 0xFD0U // SSI Peripheral Identification 4
#define SSI_O_PERIPHID5 0xFD4U // SSI Peripheral Identification 5
#define SSI_O_PERIPHID6 0xFD8U // SSI Peripheral Identification 6
#define SSI_O_PERIPHID7 0xFDCU // SSI Peripheral Identification 7
#define SSI_O_PERIPHID0 0xFE0U // SSI Peripheral Identification 0
#define SSI_O_PERIPHID1 0xFE4U // SSI Peripheral Identification 1
#define SSI_O_PERIPHID2 0xFE8U // SSI Peripheral Identification 2
#define SSI_O_PERIPHID3 0xFECU // SSI Peripheral Identification 3
#define SSI_O_PCELLID0 0xFF0U // SSI PrimeCell Identification 0
#define SSI_O_PCELLID1 0xFF4U // SSI PrimeCell Identification 1
#define SSI_O_PCELLID2 0xFF8U // SSI PrimeCell Identification 2
#define SSI_O_PCELLID3 0xFFCU // SSI PrimeCell Identification 3
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSICR0 register
//
//*************************************************************************************************
#define SSI_CR0_DSS_S 0U
#define SSI_CR0_DSS_M 0xFU // SSI Data Size Select
#define SSI_CR0_FRF_S 4U
#define SSI_CR0_FRF_M 0x30U // SSI FRame Format Select
#define SSI_CR0_SPO 0x40U // SSI Serial clock POlarity
#define SSI_CR0_SPH 0x80U // SSI Serial clock PHase
#define SSI_CR0_SCR_S 8U
#define SSI_CR0_SCR_M 0xFF00U // SSI Serial Clock Rate
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSICR1 register
//
//*************************************************************************************************
#define SSI_CR1_LBM 0x1U // SSI Loopback Mode
#define SSI_CR1_SSE 0x2U // SSI Synchronous Serial Port Enable
#define SSI_CR1_MS 0x4U // SSI Master/Slave Select
#define SSI_CR1_EOT 0x10U // End of Transmission
#define SSI_CR1_DIR 0x100U // SSI Direction of Operation
#define SSI_CR1_HSCLKEN 0x200U // High Speed Clock Enable
#define SSI_CR1_FSSHLDFRM 0x400U // FSS Hold Frame
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIDR register
//
//*************************************************************************************************
#define SSI_DR_DATA_S 0U
#define SSI_DR_DATA_M 0xFFFFU // SSI Receive/Transmit Data
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSISR register
//
//*************************************************************************************************
#define SSI_SR_TFE 0x1U // SSI Transmit FIFO Empty
#define SSI_SR_TNF 0x2U // SSI Transmit FIFO Not Full
#define SSI_SR_RNE 0x4U // SSI Receive FIFO Not Empty
#define SSI_SR_RFF 0x8U // SSI Receive FIFO Full
#define SSI_SR_BSY 0x10U // SSI Busy Bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSICPSR register
//
//*************************************************************************************************
#define SSI_CPSR_CPSDVSR_S 0U
#define SSI_CPSR_CPSDVSR_M 0xFFU // SSI Clock Prescale Divisor
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIIM register
//
//*************************************************************************************************
#define SSI_IM_RORIM 0x1U // SSI Receive Overrun Interrupt Mask
#define SSI_IM_RTIM 0x2U // SSI Receive Time-Out Interrupt Mask
#define SSI_IM_RXIM 0x4U // SSI Receive FIFO Interrupt Mask
#define SSI_IM_TXIM 0x8U // SSI Transmit FIFO Interrupt Mask
#define SSI_IM_DMARXIM 0x10U // SSI Receive DMA Interrupt Mask
#define SSI_IM_DMATXIM 0x20U // SSI Transmit DMA Interrupt Mask
#define SSI_IM_EOTIM 0x40U // End of Transmit Interrupt Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIRIS register
//
//*************************************************************************************************
#define SSI_RIS_RORRIS 0x1U // SSI Receive Overrun Raw Interrupt Status
#define SSI_RIS_RTRIS 0x2U // SSI Receive Time-Out Raw Interrupt Status
#define SSI_RIS_RXRIS 0x4U // SSI Receive FIFO Raw Interrupt Status
#define SSI_RIS_TXRIS 0x8U // SSI Transmit FIFO Raw Interrupt Status
#define SSI_RIS_DMARXRIS 0x10U // SSI Receive DMA Raw Interrupt Status
#define SSI_RIS_DMATXRIS 0x20U // SSI Transmit DMA Raw Interrupt Status
#define SSI_RIS_EOTRIS 0x40U // End of Transmit Raw Interrupt Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIMIS register
//
//*************************************************************************************************
#define SSI_MIS_RORMIS 0x1U // SSI Receive Overrun Masked Interrupt Status
#define SSI_MIS_RTMIS 0x2U // SSI Receive Time-Out Masked Interrupt Status
#define SSI_MIS_RXMIS 0x4U // SSI Receive FIFO Masked Interrupt Status
#define SSI_MIS_TXMIS 0x8U // SSI Transmit FIFO Masked Interrupt Status
#define SSI_MIS_DMARXMIS 0x10U // SSI Receive DMA Masked Interrupt Status
#define SSI_MIS_DMATXMIS 0x20U // SSI Transmit DMA Masked Interrupt Status
#define SSI_MIS_EOTMIS 0x40U // End of Transmit Masked Interrupt Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIICR register
//
//*************************************************************************************************
#define SSI_ICR_RORIC 0x1U // SSI Receive Overrun Interrupt Clear
#define SSI_ICR_RTIC 0x2U // SSI Receive Time-Out Interrupt Clear
#define SSI_ICR_DMARXIC 0x10U // SSI Receive DMA Interrupt Clear
#define SSI_ICR_DMATXIC 0x20U // SSI Transmit DMA Interrupt Clear
#define SSI_ICR_EOTIC 0x40U // End of Transmit Interrupt Clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIDMACTL register
//
//*************************************************************************************************
#define SSI_DMACTL_RXDMAE 0x1U // Receive DMA Enable
#define SSI_DMACTL_TXDMAE 0x2U // Transmit DMA Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPV register
//
//*************************************************************************************************
#define SSI_PV_MINOR_S 0U
#define SSI_PV_MINOR_M 0xFFU // Minor Revision
#define SSI_PV_MAJOR_S 8U
#define SSI_PV_MAJOR_M 0xFF00U // Major Revision
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPP register
//
//*************************************************************************************************
#define SSI_PP_HSCLK 0x1U // High Speed Capability
#define SSI_PP_MODE_S 1U
#define SSI_PP_MODE_M 0x6U // Mode of Operation
#define SSI_PP_FSSHLDFRM 0x8U // SSInFss Hold Frame Capability
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID4 register
//
//*************************************************************************************************
#define SSI_PERIPHID4_PID4_S 0U
#define SSI_PERIPHID4_PID4_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID5 register
//
//*************************************************************************************************
#define SSI_PERIPHID5_PID5_S 0U
#define SSI_PERIPHID5_PID5_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID6 register
//
//*************************************************************************************************
#define SSI_PERIPHID6_PID6_S 0U
#define SSI_PERIPHID6_PID6_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID7 register
//
//*************************************************************************************************
#define SSI_PERIPHID7_PID7_S 0U
#define SSI_PERIPHID7_PID7_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID0 register
//
//*************************************************************************************************
#define SSI_PERIPHID0_PID0_S 0U
#define SSI_PERIPHID0_PID0_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID1 register
//
//*************************************************************************************************
#define SSI_PERIPHID1_PID1_S 0U
#define SSI_PERIPHID1_PID1_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID2 register
//
//*************************************************************************************************
#define SSI_PERIPHID2_PID2_S 0U
#define SSI_PERIPHID2_PID2_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPeriphID3 register
//
//*************************************************************************************************
#define SSI_PERIPHID3_PID3_S 0U
#define SSI_PERIPHID3_PID3_M 0xFFU // SSI Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPCellID0 register
//
//*************************************************************************************************
#define SSI_PCELLID0_CID0_S 0U
#define SSI_PCELLID0_CID0_M 0xFFU // SSI PrimeCell ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPCellID1 register
//
//*************************************************************************************************
#define SSI_PCELLID1_CID1_S 0U
#define SSI_PCELLID1_CID1_M 0xFFU // SSI PrimeCell ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPCellID2 register
//
//*************************************************************************************************
#define SSI_PCELLID2_CID2_S 0U
#define SSI_PCELLID2_CID2_M 0xFFU // SSI PrimeCell ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SSIPCellID3 register
//
//*************************************************************************************************
#define SSI_PCELLID3_CID3_S 0U
#define SSI_PCELLID3_CID3_M 0xFFU // SSI PrimeCell ID Register
#endif
@@ -0,0 +1,252 @@
//###########################################################################
//
// FILE: hw_sysctl.h
//
// TITLE: Definitions for the SYSCTL registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_SYSCTL_H
#define HW_SYSCTL_H
//*************************************************************************************************
//
// The following are defines for the SYSCTL register offsets
//
//*************************************************************************************************
#define SYSCTL_O_CMPCLKCR0 0x0U // CM Peripheral clock gating register 0.
#define SYSCTL_O_CMPCLKCR1 0x4U // CM Peripheral clock gating register 1.
#define SYSCTL_O_CMPCLKCR2 0x8U // CM Peripheral clock gating register 2.
#define SYSCTL_O_CMSOFTPRESET0 0x20U // CM Software Peripheral Reset register 0
#define SYSCTL_O_CMSOFTPRESET1 0x24U // CM Software Peripheral Reset register 1
#define SYSCTL_O_CMSOFTPRESET2 0x28U // CM Software Peripheral Reset register 2
#define SYSCTL_O_CMCLKSTOPREQ0 0x40U // Peripheral Clock Stop Request Register 0
#define SYSCTL_O_CMCLKSTOPREQ1 0x44U // Peripheral Clock Stop Request Register 1
#define SYSCTL_O_CMCLKSTOPREQ2 0x48U // Peripheral Clock Stop Request Register 2
#define SYSCTL_O_CMCLKSTOPACK1 0x64U // Peripheral Clock Stop Ackonwledge Register 1
#define SYSCTL_O_MCANWAKESTATUS 0xE0U // MCAN Wake Status Register
#define SYSCTL_O_MCANWAKESTATUSCLR 0xE4U // MCAN Wake Status Clear Register
#define SYSCTL_O_PALLOCATESTS 0x1F4U // Status of PALLOCATE register.
#define SYSCTL_O_CMRESCCLR 0x1F8U // CM Reset Cause Status Clear Register
#define SYSCTL_O_CMRESC 0x1FCU // CM Reset Cause Status Register
#define SYSCTL_O_CMSYSCTLLOCK 0x200U // Locks the configuration registers of CM System
// control
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMPCLKCR0 register
//
//*************************************************************************************************
#define SYSCTL_CMPCLKCR0_UART0 0x1U // UART0 Clock gating Bit
#define SYSCTL_CMPCLKCR0_SSI0 0x10U // SSI0 Clock gating Bit
#define SYSCTL_CMPCLKCR0_I2C0 0x100U // I2C0 Clock gating Bit
#define SYSCTL_CMPCLKCR0_USB 0x1000U // USB Clock gating Bit
#define SYSCTL_CMPCLKCR0_KEY_S 16U
#define SYSCTL_CMPCLKCR0_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMPCLKCR1 register
//
//*************************************************************************************************
#define SYSCTL_CMPCLKCR1_ETHERNET 0x1U // ETHERNET Clock gating Bit
#define SYSCTL_CMPCLKCR1_ETHERCAT 0x4U // ETHERCAT Clock gating Bit
#define SYSCTL_CMPCLKCR1_CAN_A 0x10U // CAN_A Clock gating Bit
#define SYSCTL_CMPCLKCR1_CAN_B 0x20U // CAN_B Clock gating Bit
#define SYSCTL_CMPCLKCR1_MCAN_A 0x100U // MCAN_A Clock gating Bit
#define SYSCTL_CMPCLKCR1_KEY_S 16U
#define SYSCTL_CMPCLKCR1_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMPCLKCR2 register
//
//*************************************************************************************************
#define SYSCTL_CMPCLKCR2_CPUTIMER0 0x1U // CPUTIMER0 Clock gating Bit
#define SYSCTL_CMPCLKCR2_CPUTIMER1 0x2U // CPUTIMER1 Clock gating Bit
#define SYSCTL_CMPCLKCR2_CPUTIMER2 0x4U // CPUTIMER2 Clock gating Bit
#define SYSCTL_CMPCLKCR2_UDMA 0x10U // UDMA Clock gating Bit
#define SYSCTL_CMPCLKCR2_AESIP 0x40U // AESIP Clock gating Bit
#define SYSCTL_CMPCLKCR2_GCRC 0x100U // GCRC Clock gating Bit
#define SYSCTL_CMPCLKCR2_KEY_S 16U
#define SYSCTL_CMPCLKCR2_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMSOFTPRESET0 register
//
//*************************************************************************************************
#define SYSCTL_CMSOFTPRESET0_UART0 0x1U // UART0 Soft reset bit
#define SYSCTL_CMSOFTPRESET0_SSI0 0x10U // SSI0 Soft reset bit
#define SYSCTL_CMSOFTPRESET0_I2C0 0x100U // I2C0 Soft reset bit
#define SYSCTL_CMSOFTPRESET0_USB 0x1000U // USB Soft reset bit
#define SYSCTL_CMSOFTPRESET0_KEY_S 16U
#define SYSCTL_CMSOFTPRESET0_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMSOFTPRESET1 register
//
//*************************************************************************************************
#define SYSCTL_CMSOFTPRESET1_ETHERNET 0x1U // ETHERNET Soft reset bit
#define SYSCTL_CMSOFTPRESET1_ETHERCAT 0x4U // ETHERCAT Soft reset bit
#define SYSCTL_CMSOFTPRESET1_CAN_A 0x10U // CAN_A Soft reset bit
#define SYSCTL_CMSOFTPRESET1_CAN_B 0x20U // CAN_B Soft reset bit
#define SYSCTL_CMSOFTPRESET1_MCAN_A 0x100U // MCAN_A Soft reset bit
#define SYSCTL_CMSOFTPRESET1_KEY_S 16U
#define SYSCTL_CMSOFTPRESET1_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMSOFTPRESET2 register
//
//*************************************************************************************************
#define SYSCTL_CMSOFTPRESET2_AESIP 0x40U // AESIP Soft reset bit
#define SYSCTL_CMSOFTPRESET2_GCRC 0x100U // GCRC Soft reset bit
#define SYSCTL_CMSOFTPRESET2_KEY_S 16U
#define SYSCTL_CMSOFTPRESET2_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMCLKSTOPREQ0 register
//
//*************************************************************************************************
#define SYSCTL_CMCLKSTOPREQ0_KEY_S 16U
#define SYSCTL_CMCLKSTOPREQ0_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMCLKSTOPREQ1 register
//
//*************************************************************************************************
#define SYSCTL_CMCLKSTOPREQ1_MCAN_A 0x100U // MCAN_A Clock Stop Request Bit
#define SYSCTL_CMCLKSTOPREQ1_KEY_S 16U
#define SYSCTL_CMCLKSTOPREQ1_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMCLKSTOPREQ2 register
//
//*************************************************************************************************
#define SYSCTL_CMCLKSTOPREQ2_KEY_S 16U
#define SYSCTL_CMCLKSTOPREQ2_KEY_M 0xFFFF0000U // Key field
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMCLKSTOPACK1 register
//
//*************************************************************************************************
#define SYSCTL_CMCLKSTOPACK1_MCAN_A 0x100U // MCAN_A Clock Stop Ack Bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the MCANWAKESTATUS register
//
//*************************************************************************************************
#define SYSCTL_MCANWAKESTATUS_WAKE 0x1U // MCAN Wake Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the MCANWAKESTATUSCLR register
//
//*************************************************************************************************
#define SYSCTL_MCANWAKESTATUSCLR_WAKE 0x1U // Cear bit for MCANWAKESTATUS.WAKE bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the PALLOCATESTS register
//
//*************************************************************************************************
#define SYSCTL_PALLOCATESTS_USB 0x1U // Status of PALLOCATE.USB bit
#define SYSCTL_PALLOCATESTS_ETHERCAT 0x2U // Status of PALLOCATE.ETHERCAT bit
#define SYSCTL_PALLOCATESTS_CAN_A 0x4U // Status of PALLOCATE.CAN_A bit
#define SYSCTL_PALLOCATESTS_CAN_B 0x8U // Status of PALLOCATE.CAN_B bit
#define SYSCTL_PALLOCATESTS_MCAN_A 0x10U // Status of PALLOCATE.MCAN_A bit
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMRESCCLR register
//
//*************************************************************************************************
#define SYSCTL_CMRESCCLR_PORESETN 0x1U // PORESETn status flag clear
#define SYSCTL_CMRESCCLR_XRSN 0x2U // XRSn status flag clear
#define SYSCTL_CMRESCCLR_CPU1WDRSN 0x4U // CPU1WDRSn status flag clear
#define SYSCTL_CMRESCCLR_CPU1NMIWDRSN 0x8U // CPU1NMIWDRSn status flag clear
#define SYSCTL_CMRESCCLR_CPU1SYSRSN 0x10U // CPU1SYSRSN status flag clear
#define SYSCTL_CMRESCCLR_CPU1SCCRESETN 0x20U // CPU1SCCRESETn status flag clear
#define SYSCTL_CMRESCCLR_ECAT_RESET_OUT 0x40U // ECAT_RESET_OUT status flag clear
#define SYSCTL_CMRESCCLR_CPU1SIMRESET_CPURSN 0x80U // CPU1SIMRESET_CPURSn status flag clear
#define SYSCTL_CMRESCCLR_CMRSTCTLRESETREQ 0x100U // CMRSTCTLRESETREQ status flag clear
#define SYSCTL_CMRESCCLR_CPU1_SIMRESET_XRSN 0x200U // CPU1_SIMRESET_XRSn status flag clear
#define SYSCTL_CMRESCCLR_CMVECTRESETN 0x10000U // CMVECTRESETn status flag clear
#define SYSCTL_CMRESCCLR_CMSYSRESETREQ 0x20000U // CMSYSRESETREQ status flag clear
#define SYSCTL_CMRESCCLR_CMNMIWDRSTN 0x40000U // CMNMIWDRSTn status flag clear
#define SYSCTL_CMRESCCLR_CMEOLRESETN 0x80000U // CMEOLRESETn status flag clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMRESC register
//
//*************************************************************************************************
#define SYSCTL_CMRESC_PORESETN 0x1U // PORESETn caused the reset of CM
#define SYSCTL_CMRESC_XRSN 0x2U // XRSn caused the reset of CM
#define SYSCTL_CMRESC_CPU1_WDRSN 0x4U // CPU1_WDRSn caused the reset of CM
#define SYSCTL_CMRESC_CPU1_NMIWDRSN 0x8U // CPU1_NMIWDRSn caused the reset of CM
#define SYSCTL_CMRESC_CPU1_SYSRSN 0x10U // CPU1_SYSRSN caused the reset of CM
#define SYSCTL_CMRESC_CPU1_SCCRESETN 0x20U // CPU1_SCCRESETn caused the reset of CM
#define SYSCTL_CMRESC_ECAT_RESET_OUT 0x40U // ECAT_RESET_OUT caused the reset of CM
#define SYSCTL_CMRESC_CPU1_SIMRESET_CPURSN 0x80U // CPU1_SIMRESET_CPURSn caused the reset of
// CM
#define SYSCTL_CMRESC_CMRSTCTL_RESETREQ 0x100U // CMRSTCTL_RESETREQ caused the reset of CM
#define SYSCTL_CMRESC_CPU1_SIMRESET_XRSN 0x200U // CPU1_SIMRESET_XRSn caused the reset of
// CM
#define SYSCTL_CMRESC_CMVECTRESETN 0x10000U // CMVECTRESETn caused the reset of CM
#define SYSCTL_CMRESC_CMSYSRESETREQ 0x20000U // CMSYSRESETREQ caused the reset of CM
#define SYSCTL_CMRESC_CMNMIWDRSTN 0x40000U // CMNMIWDRSTn caused the reset of CM
#define SYSCTL_CMRESC_CMEOLRESETN 0x80000U // CMEOLRESETn caused the reset of CM
//*************************************************************************************************
//
// The following are defines for the bit fields in the CMSYSCTLLOCK register
//
//*************************************************************************************************
#define SYSCTL_CMSYSCTLLOCK_LOCK 0x1U // Locks the configuration registers of CM System Control
#endif
@@ -0,0 +1,84 @@
//*****************************************************************************
//
// hw_types.h - Common types and macros.
//
// Copyright (c) 2005-2016 Texas Instruments Incorporated. All rights reserved.
// Software License Agreement
//
// 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.
//
// This is part of revision 2.1.3.156 of the Tiva Firmware Development Package.
//
//*****************************************************************************
#ifndef __HW_TYPES_H__
#define __HW_TYPES_H__
//*****************************************************************************
//
// Macros for hardware access, both direct and via the bit-band region.
//
//*****************************************************************************
#define HWREG(x) \
(*((volatile uint32_t *)(x)))
#define HWREGH(x) \
(*((volatile uint16_t *)(x)))
#define HWREGB(x) \
(*((volatile uint8_t *)(x)))
#define HWREGBITW(x, b) \
HWREG(((uint32_t)(x) & 0xF0000000) | 0x02000000 | \
(((uint32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
#define HWREGBITH(x, b) \
HWREGH(((uint32_t)(x) & 0xF0000000) | 0x02000000 | \
(((uint32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
#define HWREGBITB(x, b) \
HWREGB(((uint32_t)(x) & 0xF0000000) | 0x02000000 | \
(((uint32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
//
// The HWREG_BP Define uses __byte_peripheral_32 intrinsic which can be
// used to access a 32-bit byte peripherals data address, preventing the
// accesses from being broken up. The intrinsic returns a reference to an
// unsigned long and can be used both to read and write data. This is
// applicable for the C28x Driver and is not applicable for CM Driver. Thus
// the define HWREG_BP has been mapped to HWREG.
//
#define HWREG_BP(x) \
HWREG(x)
//****************************************************************************
//
// For checking NULL pointers
//
//****************************************************************************
#ifndef NULL
#define NULL ((void *)0x0)
#endif
#endif // __HW_TYPES_H__
@@ -0,0 +1,690 @@
/**
* \file hw_types.h
*
* \brief This file contains the in-line functions required to read/write
* values from/to the hardware registers. This file also contains field
* manipulation macros to get and set field values.
*
* \copyright Copyright (C) 2013 Texas Instruments Incorporated - 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.
*
*/
#ifndef HW_TYPES_H_
#define HW_TYPES_H_
/* ========================================================================== */
/* Include Files */
/* ========================================================================== */
#ifdef __cplusplus
extern "C" {
#endif
/* ========================================================================== */
/* Macros & Typedefs */
/* ========================================================================== */
/**
* \brief This macro reads a 32-bit value from a hardware register
* and returns the value.
*
* \param addr Address of the memory mapped hardware register.
*
* \return Unsigned 32-bit value read from a register.
*/
#define HW_RD_REG32(addr) (uint32_t)(HW_RD_REG32_RAW((uint32_t) (addr)))
/**
* \brief This macro writes a 32-bit value to a hardware register.
*
* \param addr Address of the memory mapped hardware register.
* \param value unsigned 32-bit value which has to be written to the
* register.
*/
#define HW_WR_REG32(addr, value) \
(HW_WR_REG32_RAW((uint32_t) (addr), (uint32_t) (value)))
/**
* \brief This macro reads a 16-bit value from a hardware register
* and returns the value.
*
* \param addr Address of the memory mapped hardware register.
*
* \return Unsigned 16-bit value read from a register.
*/
#define HW_RD_REG16(addr) (HW_RD_REG16_RAW((uint32_t) (addr)))
/**
* \brief This macro writes a 16-bit value to a hardware register.
*
* \param addr Address of the memory mapped hardware register.
* \param value unsigned 16-bit value which has to be written to the
* register.
*/
#define HW_WR_REG16(addr, value) \
(HW_WR_REG16_RAW((uint32_t) (addr), (uint16_t) (value)))
/**
* \brief This macro reads a 8-bit value from a hardware register
* and returns the value.
*
* \param addr Address of the memory mapped hardware register.
*
* \return Unsigned 8-bit value read from a register.
*/
#define HW_RD_REG8(addr) (HW_RD_REG8_RAW((uint32_t) (addr)))
/**
* \brief This macro writes a 8-bit value to a hardware
* register.
*
* \param addr Address of the memory mapped hardware register.
* \param value unsigned 8-bit value which has to be written to the
* register.
*/
#define HW_WR_REG8(addr, value) \
(HW_WR_REG8_RAW((uint32_t) (addr), (uint8_t) (value)))
/**
* \brief Macro to extract a field value. This macro extracts the field value
* from a 32-bit variable (which contains the register value).
* This macro does not read from actual register address, and only
* extracts the field from a variable.
*
* \param regVal 32-bit variable containing the register value.
* \param REG_FIELD Peripheral register bit field name, whose value has to
* be extracted.
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_GET_FIELD(regVal, REG_FIELD) \
(((regVal) & (uint32_t) REG_FIELD##_MASK) >> (uint32_t) REG_FIELD##_SHIFT)
/**
* \brief Macro to write a specific field value. This macro first clears the
* specified field value and then performs "OR" of the field value which
* is shifted and masked. This will set the field value at its
* desired position.
*
* \param regVal 32-bit variable containing the register value.
* \param REG_FIELD Peripheral register bit field name, to which specified
* value has to be set.
* \param fieldVal Value of the field which has to be set.
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_SET_FIELD32(regVal, REG_FIELD, fieldVal) \
((regVal) = ((regVal) & (uint32_t) (~(uint32_t) REG_FIELD##_MASK)) | \
((((uint32_t) (fieldVal)) << (uint32_t) REG_FIELD##_SHIFT) \
& (uint32_t) REG_FIELD##_MASK))
/**
* \brief Macro to write a specific field value. This macro first clears the
* specified field value and then performs "OR" of the field value which
* is shifted and masked. This will set the field value at its
* desired position.
*
* \param regVal 16-bit variable containing the register value.
* \param REG_FIELD Peripheral register bit field name, to which specified
* value has to be set.
* \param fieldVal Value of the field which has to be set.
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_SET_FIELD16(regVal, REG_FIELD, fieldVal) \
((regVal) = ((regVal) & (uint16_t) (~(uint16_t) REG_FIELD##_MASK)) | \
((((uint16_t) (fieldVal)) << (uint16_t) REG_FIELD##_SHIFT) \
& (uint16_t) REG_FIELD##_MASK))
/**
* \brief Macro to write a specific field value. This macro first clears the
* specified field value and then performs "OR" of the field value which
* is shifted and masked. This will set the field value at its
* desired position.
*
* \param regVal 8-bit variable containing the register value.
* \param REG_FIELD Peripheral register bit field name, to which specified
* value has to be set.
* \param fieldVal Value of the field which has to be set.
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_SET_FIELD8(regVal, REG_FIELD, fieldVal) \
((regVal) = ((regVal) & (uint8_t) (~(uint8_t) REG_FIELD##_MASK)) | \
((((uint8_t) (fieldVal)) << (uint8_t) REG_FIELD##_SHIFT) \
& (uint8_t) REG_FIELD##_MASK))
/**
* \brief This macro calls read-modify-write API for 32 bit register. It also
* frames the mask and shift from register field macro.
*
* \param regAddr Register Address.
* \param REG_FIELD Peripheral register bit field name, to which specified
* value has to be set.
* \param fieldVal Value of the field which has to be set.
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_WR_FIELD32(regAddr, REG_FIELD, fieldVal) \
(HW_WR_FIELD32_RAW((uint32_t) (regAddr), (uint32_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT, (uint32_t) (fieldVal)))
/**
* \brief This macro calls read-modify-write API for 16 bit register. It also
* frames the mask and shift from register field macro.
*
* \param regAddr Register Address.
* \param REG_FIELD Peripheral register bit field name, to which specified
* value has to be set.
* \param fieldVal Value of the field which has to be set.
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_WR_FIELD16(regAddr, REG_FIELD, fieldVal) \
(HW_WR_FIELD16_RAW((uint32_t) (regAddr), (uint16_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT, (uint16_t) (fieldVal)))
/**
* \brief This macro calls read-modify-write API for 8 bit register. It also
* frames the mask and shift from register field macro.
*
* \param regAddr Register Address.
* \param REG_FIELD Peripheral register bit field name, to which specified
* value has to be set.
* \param fieldVal Value of the field which has to be set.
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_WR_FIELD8(regAddr, REG_FIELD, fieldVal) \
(HW_WR_FIELD8_RAW((uint32_t) (regAddr), (uint8_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT, (uint8_t) (fieldVal)))
/**
* \brief This macro calls read field API for 32 bit register. It also
* frames the mask and shift from register field macro.
*
* \param regAddr Register Address.
* \param REG_FIELD Peripheral register bit field name, from which
* specified bit-field value has to be read.
* \return Value of the bit-field
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_RD_FIELD32(regAddr, REG_FIELD) \
(HW_RD_FIELD32_RAW((uint32_t) (regAddr), (uint32_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT))
/**
* \brief This macro calls read field API for 16 bit register. It also
* frames the mask and shift from register field macro.
*
* \param regAddr Register Address.
* \param REG_FIELD Peripheral register bit field name, from which
* specified bit-field value has to be read.
* \return Value of the bit-field
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_RD_FIELD16(regAddr, REG_FIELD) \
(HW_RD_FIELD16_RAW((uint32_t) (regAddr), (uint16_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT))
/**
* \brief This macro calls read field API for 8 bit register. It also
* frames the mask and shift from register field macro.
*
* \param regAddr Register Address.
* \param REG_FIELD Peripheral register bit field name, from which
* specified bit-field value has to be read.
* \return Value of the bit-field
*/
/*TI_INSPECTED 76 S : MISRAC_2012_R.20.11
* "The places in which order of evaluation has no side effects could be a
waiver. This used in SHIFT and MASK to extract specified field value " */
/*TI_INSPECTED 125 S : MISRAC_2012_R.20.12
* "The places in which order of evaluation has no side effects could be a
waiver. ## operator here used in SHIFT and MASK to extract specified field
value " */
#define HW_RD_FIELD8(regAddr, REG_FIELD) \
(HW_RD_FIELD8_RAW((uint32_t) (regAddr), (uint8_t) REG_FIELD##_MASK, \
(uint32_t) REG_FIELD##_SHIFT))
/* ========================================================================== */
/* Structures and Enums */
/* ========================================================================== */
/* None */
/* ========================================================================== */
/* Global Variables Declarations */
/* ========================================================================== */
/* None */
/* ========================================================================== */
/* Function Declarations */
/* ========================================================================== */
/**
* \brief This function reads a 32-bit value from a hardware register
* and returns the value.
*
* \param addr Address of the memory mapped hardware register.
*
* \return Unsigned 32-bit value read from a register.
*/
static inline uint32_t HW_RD_REG32_RAW(uint32_t addr);
/**
* \brief This function writes a 32-bit value to a hardware register.
*
* \param addr Address of the memory mapped hardware register.
* \param value unsigned 32-bit value which has to be written to the
* register.
*/
static inline void HW_WR_REG32_RAW(uint32_t addr, uint32_t value);
/**
* \brief This function reads a 16-bit value from a hardware register
* and returns the value.
*
* \param addr Address of the memory mapped hardware register.
*
* \return Unsigned 16-bit value read from a register.
*/
static inline uint16_t HW_RD_REG16_RAW(uint32_t addr);
/**
* \brief This function writes a 16-bit value to a hardware register.
*
* \param addr Address of the memory mapped hardware register.
* \param value unsigned 16-bit value which has to be written to the
* register.
*/
static inline void HW_WR_REG16_RAW(uint32_t addr, uint16_t value);
/**
* \brief This function reads a 8-bit value from a hardware register
* and returns the value.
*
* \param addr Address of the memory mapped hardware register.
*
* \return Unsigned 8-bit value read from a register.
*/
static inline uint8_t HW_RD_REG8_RAW(uint32_t addr);
/**
* \brief This function writes a 8-bit value to a hardware
* register.
*
* \param addr Address of the memory mapped hardware register.
* \param value unsigned 8-bit value which has to be written to the
* register.
*/
static inline void HW_WR_REG8_RAW(uint32_t addr, uint8_t value);
/**
* \brief This function reads a 32 bit register, modifies specific set of
* bits and writes back to the register.
*
* \param addr Address of the memory mapped hardware register.
* \param mask Mask for the bit field.
* \param shift Bit field shift from LSB.
* \param value Value to be written to bit-field.
*/
static inline void HW_WR_FIELD32_RAW(uint32_t addr,
uint32_t mask,
uint32_t shift,
uint32_t value);
/**
* \brief This function reads a 16 bit register, modifies specific set of
* bits and writes back to the register.
*
* \param addr Address of the memory mapped hardware register.
* \param mask Mask for the bit field.
* \param shift Bit field shift from LSB.
* \param value Value to be written to bit-field.
*/
static inline void HW_WR_FIELD16_RAW(uint32_t addr,
uint16_t mask,
uint32_t shift,
uint16_t value);
/**
* \brief This function reads a 8 bit register, modifies specific set of
* bits and writes back to the register.
*
* \param addr Address of the memory mapped hardware register.
* \param mask Mask for the bit field.
* \param shift Bit field shift from LSB.
* \param value Value to be written to bit-field.
*/
static inline void HW_WR_FIELD8_RAW(uint32_t addr,
uint8_t mask,
uint32_t shift,
uint8_t value);
/**
* \brief This function reads a 32 bit register, masks specific set of bits
* and the left shifted value.
*
* \param addr Address of the memory mapped hardware register.
* \param mask Mask for the bit field.
* \param shift Bit field shift from LSB.
*
* \return Bit-field value (absolute value - shifted to LSB position)
*/
static inline uint32_t HW_RD_FIELD32_RAW(uint32_t addr,
uint32_t mask,
uint32_t shift);
/**
* \brief This function reads a 16 bit register, masks specific set of bits
* and the left shifted value.
*
* \param addr Address of the memory mapped hardware register.
* \param mask Mask for the bit field.
* \param shift Bit field shift from LSB.
*
* \return Bit-field value (absolute value - shifted to LSB position)
*/
static inline uint16_t HW_RD_FIELD16_RAW(uint32_t addr,
uint16_t mask,
uint32_t shift);
/**
* \brief This function reads a 8 bit register, masks specific set of bits
* and the left shifted value.
*
* \param addr Address of the memory mapped hardware register.
* \param mask Mask for the bit field.
* \param shift Bit field shift from LSB.
*
* \return Bit-field value (absolute value - shifted to LSB position)
*/
static inline uint8_t HW_RD_FIELD8_RAW(uint32_t addr,
uint8_t mask,
uint32_t shift);
/* ========================================================================== */
/* Static Function Definitions */
/* ========================================================================== */
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_RD_REG32 mcaro " */
/*TI_INSPECTED 101 S : MISRAC_2012_R.10.3
* "Reason - Tool Issue: Not able to understand Inline Function return type " */
/*TI_INSPECTED 102 S : MISRAC_2012_R.8.4
* "Reason - Tool Issue: Not able to understand Inline Function return type " */
static inline uint32_t HW_RD_REG32_RAW(uint32_t addr)
{
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint32_t regVal = *(volatile uint32_t *) addr;
return (regVal);
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_WR_REG32 mcaro " */
/*TI_INSPECTED 131 S : MISRAC_2012_R.5.3
* "Tool Issue - argument 'value' used here is in same scope " */
/*TI_INSPECTED 14 D 1: MISRAC_2012_R.5.8
* "Tool Issue - Modifying the contents stored at address not the addr itself */
static inline void HW_WR_REG32_RAW(uint32_t addr, uint32_t value)
{
/*TI_INSPECTED 18 D : MISRAC_2012_R.5.3
* "Tool Issue - argument 'value' used here is in same scope " */
*(volatile uint32_t *) addr = value;
return;
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_RD_REG16 mcaro " */
static inline uint16_t HW_RD_REG16_RAW(uint32_t addr)
{
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint16_t regVal = *(volatile uint16_t *) addr;
return (regVal);
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_WR_REG16 mcaro " */
/*TI_INSPECTED 131 S : MISRAC_2012_R.5.3
* "Tool Issue - argument 'value' used here is in same scope " */
/*TI_INSPECTED 14 D 1: MISRAC_2012_R.5.8
* "Tool Issue - Modifying the contents stored at address not the addr itself */
static inline void HW_WR_REG16_RAW(uint32_t addr, uint16_t value)
{
/*TI_INSPECTED 18 D : MISRAC_2012_R.5.3
* "Tool Issue - argument 'value' used here is in same scope " */
*(volatile uint16_t *) addr = value;
return;
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_RD_REG8 mcaro " */
static inline uint8_t HW_RD_REG8_RAW(uint32_t addr)
{
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint8_t regVal = *(volatile uint8_t *) addr;
return (regVal);
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_WR_REG8 mcaro " */
/*TI_INSPECTED 131 S : MISRAC_2012_R.5.3
* "Tool Issue - argument 'value' used here is in same scope " */
/*TI_INSPECTED 14 D 1: MISRAC_2012_R.5.8
* "Tool Issue - Modifying the contents stored at address not the addr itself */
static inline void HW_WR_REG8_RAW(uint32_t addr, uint8_t value)
{
/*TI_INSPECTED 18 D : MISRAC_2012_R.5.3
* "Tool Issue - argument 'value' used here is in same scope " */
*(volatile uint8_t *) addr = value;
return;
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_WR_FIELD32 mcaro " */
/*TI_INSPECTED 14 D 1: MISRAC_2012_R.5.8
* "Tool Issue - Modifying the contents stored at address not the addr itself */
static inline void HW_WR_FIELD32_RAW(uint32_t addr,
uint32_t mask,
uint32_t shift,
uint32_t value)
{
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint32_t regVal = *(volatile uint32_t *) addr;
regVal &= (~mask);
regVal |= (value << shift) & mask;
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
*(volatile uint32_t *) addr = regVal;
return;
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_WR_FIELD16 mcaro " */
/*TI_INSPECTED 14 D 1: MISRAC_2012_R.5.8
* "Tool Issue - Modifying the contents stored at address not the addr itself */
static inline void HW_WR_FIELD16_RAW(uint32_t addr,
uint16_t mask,
uint32_t shift,
uint16_t value)
{
uint32_t tempVal;
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint16_t regVal = *(volatile uint16_t *) addr;
tempVal = ((uint32_t) regVal);
tempVal &= (~((uint32_t) mask));
tempVal |= (((uint32_t) value) << shift) & ((uint32_t) mask);
regVal = (uint16_t) tempVal;
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
*(volatile uint16_t *) addr = regVal;
return;
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_WR_FIELD8 mcaro " */
/*TI_INSPECTED 14 D 1: MISRAC_2012_R.5.8
* "Tool Issue - Modifying the contents stored at address not the addr itself */
static inline void HW_WR_FIELD8_RAW(uint32_t addr,
uint8_t mask,
uint32_t shift,
uint8_t value)
{
uint32_t tempVal;
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint8_t regVal = *(volatile uint8_t *) addr;
tempVal = ((uint32_t) regVal);
tempVal &= (~((uint32_t) mask));
tempVal |= (((uint32_t) value) << shift) & ((uint32_t) mask);
regVal = (uint8_t) tempVal;
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
*(volatile uint8_t *) addr = regVal;
return;
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_RD_FIELD32 mcaro " */
static inline uint32_t HW_RD_FIELD32_RAW(uint32_t addr,
uint32_t mask,
uint32_t shift)
{
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint32_t regVal = *(volatile uint32_t *) addr;
regVal = (regVal & mask) >> shift;
return (regVal);
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_RD_FIELD16 mcaro " */
static inline uint16_t HW_RD_FIELD16_RAW(uint32_t addr,
uint16_t mask,
uint32_t shift)
{
uint32_t tempVal;
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint16_t regVal = *(volatile uint16_t *) addr;
tempVal = (((uint32_t) regVal & (uint32_t) mask) >> shift);
regVal = (uint16_t) tempVal;
return (regVal);
}
/*TI_INSPECTED 35 S : MISRAC_2012_R.2.1
* "Reason - This function is called using HW_RD_FIELD8 mcaro " */
static inline uint8_t HW_RD_FIELD8_RAW(uint32_t addr,
uint8_t mask,
uint32_t shift)
{
uint32_t tempVal;
/*TI_INSPECTED 440 S : MISRAC_2012_R.11.4
* "Reason - Pointer typecast required here since addr variable holds
* required register value" */
uint8_t regVal = *(volatile uint8_t *) addr;
tempVal = (((uint32_t) regVal & (uint32_t) mask) >> shift);
regVal = (uint8_t) tempVal;
return (regVal);
}
#ifdef __cplusplus
}
#endif
#endif /* #ifndef HW_TYPES_H_ */
@@ -0,0 +1,387 @@
//###########################################################################
//
// FILE: hw_uart.h
//
// TITLE: Definitions for the UART registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_UART_H
#define HW_UART_H
//*************************************************************************************************
//
// The following are defines for the UART register offsets
//
//*************************************************************************************************
#define UART_O_DR 0x0U // UART Data
#define UART_O_RSR 0x4U // UART Receive Status/Error Clear
#define UART_O_FR 0x18U // UART Flag
#define UART_O_ILPR 0x20U // UART IrDA Low-Power Register
#define UART_O_IBRD 0x24U // UART Integer Baud-Rate Divisor
#define UART_O_FBRD 0x28U // UART Fractional Baud-Rate Divisor
#define UART_O_LCRH 0x2CU // UART Line Control
#define UART_O_CTL 0x30U // UART Control
#define UART_O_IFLS 0x34U // UART Interrupt FIFO Level Select
#define UART_O_IM 0x38U // UART Interrupt Mask
#define UART_O_RIS 0x3CU // UART Raw Interrupt Status
#define UART_O_MIS 0x40U // UART Masked Interrupt Status
#define UART_O_ICR 0x44U // UART Interrupt Clear
#define UART_O_DMACTL 0x48U // UART DMA Control
#define UART_O_9BITADDR 0xA4U // UART 9-Bit Self Address
#define UART_O_9BITAMASK 0xA8U // UART 9-Bit Self Address Mask
#define UART_O_PP 0xFC0U // UART Peripheral Properties
#define UART_O_PERIPHID4 0xFD0U // UART Peripheral Identification 4
#define UART_O_PERIPHID5 0xFD4U // UART Peripheral Identification 5
#define UART_O_PERIPHID6 0xFD8U // UART Peripheral Identification 6
#define UART_O_PERIPHID7 0xFDCU // UART Peripheral Identification 7
#define UART_O_PERIPHID0 0xFE0U // UART Peripheral Identification 0
#define UART_O_PERIPHID1 0xFE4U // UART Peripheral Identification 1
#define UART_O_PERIPHID2 0xFE8U // UART Peripheral Identification 2
#define UART_O_PERIPHID3 0xFECU // UART Peripheral Identification 3
#define UART_O_PCELLID0 0xFF0U // UART PrimeCell Identification 0
#define UART_O_PCELLID1 0xFF4U // UART PrimeCell Identification 1
#define UART_O_PCELLID2 0xFF8U // UART PrimeCell Identification 2
#define UART_O_PCELLID3 0xFFCU // UART PrimeCell Identification 3
#define UART_O_ECR 0x4U // UART Error Clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTDR register
//
//*************************************************************************************************
#define UART_DR_DATA_S 0U
#define UART_DR_DATA_M 0xFFU // Data Transmitted or Received
#define UART_DR_FE 0x100U // UART Framing Error
#define UART_DR_PE 0x200U // UART Parity Error
#define UART_DR_BE 0x400U // UART Break Error
#define UART_DR_OE 0x800U // UART Overrun Error
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTRSR register
//
//*************************************************************************************************
#define UART_RSR_FE 0x1U // UART Framing Error
#define UART_RSR_PE 0x2U // UART Parity Error
#define UART_RSR_BE 0x4U // UART Break Error
#define UART_RSR_OE 0x8U // UART Overrun Error
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTFR register
//
//*************************************************************************************************
#define UART_FR_BUSY 0x8U // UART Busy
#define UART_FR_RXFE 0x10U // UART Receive FIFO Empty
#define UART_FR_TXFF 0x20U // UART Transmit FIFO Full
#define UART_FR_RXFF 0x40U // UART Receive FIFO Full
#define UART_FR_TXFE 0x80U // UART Transmit FIFO Empty
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTILPR register
//
//*************************************************************************************************
#define UART_ILPR_ILPDVSR_S 0U
#define UART_ILPR_ILPDVSR_M 0xFFU // IrDA Low-Power Divisor
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTIBRD register
//
//*************************************************************************************************
#define UART_IBRD_DIVINT_S 0U
#define UART_IBRD_DIVINT_M 0xFFFFU // Integer Baud-Rate Divisor
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTFBRD register
//
//*************************************************************************************************
#define UART_FBRD_DIVFRAC_S 0U
#define UART_FBRD_DIVFRAC_M 0x3FU // Fractional Baud-Rate Divisor
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTLCRH register
//
//*************************************************************************************************
#define UART_LCRH_BRK 0x1U // UART Send Break
#define UART_LCRH_PEN 0x2U // UART Parity Enable
#define UART_LCRH_EPS 0x4U // UART Even Parity Select
#define UART_LCRH_STP2 0x8U // UART Two Stop Bits Select
#define UART_LCRH_FEN 0x10U // UART Enable FIFOs
#define UART_LCRH_WLEN_S 5U
#define UART_LCRH_WLEN_M 0x60U // UART Word Length
#define UART_LCRH_SPS 0x80U // UART Stick Parity Select
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTCTL register
//
//*************************************************************************************************
#define UART_CTL_UARTEN 0x1U // UART Enable
#define UART_CTL_SIREN 0x2U // UART SIR Enable
#define UART_CTL_SIRLP 0x4U // UART SIR Low-Power Mode
#define UART_CTL_EOT 0x10U // End of Transmission
#define UART_CTL_HSE 0x20U // High-Speed Enable
#define UART_CTL_LBE 0x80U // UART Loop Back Enable
#define UART_CTL_TXE 0x100U // UART Transmit Enable
#define UART_CTL_RXE 0x200U // UART Receive Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTIFLS register
//
//*************************************************************************************************
#define UART_IFLS_TXIFLSEL_S 0U
#define UART_IFLS_TXIFLSEL_M 0x7U // UART Transmit Interrupt FIFO Level Select
#define UART_IFLS_RXIFLSEL_S 3U
#define UART_IFLS_RXIFLSEL_M 0x38U // UART Receive Interrupt FIFO Level Select
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTIM register
//
//*************************************************************************************************
#define UART_IM_RXIM 0x10U // UART Receive Interrupt Mask
#define UART_IM_TXIM 0x20U // UART Transmit Interrupt Mask
#define UART_IM_RTIM 0x40U // UART Receive Time-Out Interrupt Mask
#define UART_IM_FEIM 0x80U // UART Framing Error Interrupt Mask
#define UART_IM_PEIM 0x100U // UART Parity Error Interrupt Mask
#define UART_IM_BEIM 0x200U // UART Break Error Interrupt Mask
#define UART_IM_OEIM 0x400U // UART Overrun Error Interrupt Mask
#define UART_IM_9BITIM 0x1000U // 9-Bit Mode Interrupt Mask
#define UART_IM_DMARXIM 0x10000U // Receive DMA Interrupt Mask
#define UART_IM_DMATXIM 0x20000U // Transmit DMA Interrupt Mask
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTRIS register
//
//*************************************************************************************************
#define UART_RIS_RXRIS 0x10U // UART Receive Raw Interrupt Status
#define UART_RIS_TXRIS 0x20U // UART Transmit Raw Interrupt Status
#define UART_RIS_RTRIS 0x40U // UART Receive Time-Out Raw Interrupt Status
#define UART_RIS_FERIS 0x80U // UART Framing Error Raw Interrupt Status
#define UART_RIS_PERIS 0x100U // UART Parity Error Raw Interrupt Status
#define UART_RIS_BERIS 0x200U // UART Break Error Raw Interrupt Status
#define UART_RIS_OERIS 0x400U // UART Overrun Error Raw Interrupt Status
#define UART_RIS_9BITRIS 0x1000U // 9-Bit Mode Raw Interrupt Status
#define UART_RIS_DMARXRIS 0x10000U // Receive DMA Raw Interrupt Status
#define UART_RIS_DMATXRIS 0x20000U // Transmit DMA Raw Interrupt Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTMIS register
//
//*************************************************************************************************
#define UART_MIS_RXMIS 0x10U // UART Receive Masked Interrupt Status
#define UART_MIS_TXMIS 0x20U // UART Transmit Masked Interrupt Status
#define UART_MIS_RTMIS 0x40U // UART Receive Time-Out Masked Interrupt Status
#define UART_MIS_FEMIS 0x80U // UART Framing Error Masked Interrupt Status
#define UART_MIS_PEMIS 0x100U // UART Parity Error Masked Interrupt Status
#define UART_MIS_BEMIS 0x200U // UART Break Error Masked Interrupt Status
#define UART_MIS_OEMIS 0x400U // UART Overrun Error Masked Interrupt Status
#define UART_MIS_9BITMIS 0x1000U // 9-Bit Mode Masked Interrupt Status
#define UART_MIS_DMARXMIS 0x10000U // Receive DMA Masked Interrupt Status
#define UART_MIS_DMATXMIS 0x20000U // Transmit DMA Masked Interrupt Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTICR register
//
//*************************************************************************************************
#define UART_ICR_RXIC 0x10U // Receive Interrupt Clear
#define UART_ICR_TXIC 0x20U // Transmit Interrupt Clear
#define UART_ICR_RTIC 0x40U // Receive Time-Out Interrupt Clear
#define UART_ICR_FEIC 0x80U // Framing Error Interrupt Clear
#define UART_ICR_PEIC 0x100U // Parity Error Interrupt Clear
#define UART_ICR_BEIC 0x200U // Break Error Interrupt Clear
#define UART_ICR_OEIC 0x400U // Overrun Error Interrupt Clear
#define UART_ICR_EOTIC 0x800U // End of Transmission Interrupt Clear
#define UART_ICR_9BITIC 0x1000U // 9-Bit Mode Interrupt Clear
#define UART_ICR_DMARXIC 0x10000U // Receive DMA Interrupt Clear
#define UART_ICR_DMATXIC 0x20000U // Transmit DMA Interrupt Clear
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTDMACTL register
//
//*************************************************************************************************
#define UART_DMACTL_RXDMAE 0x1U // Receive DMA Enable
#define UART_DMACTL_TXDMAE 0x2U // Transmit DMA Enable
#define UART_DMACTL_DMAERR 0x4U // DMA on Error
//*************************************************************************************************
//
// The following are defines for the bit fields in the UART9BITADDR register
//
//*************************************************************************************************
#define UART_9BITADDR_ADDR_S 0U
#define UART_9BITADDR_ADDR_M 0xFFU // Self Address for 9-Bit Mode
#define UART_9BITADDR_9BITEN 0x8000U // Enable 9-Bit Mode
//*************************************************************************************************
//
// The following are defines for the bit fields in the UART9BITAMASK register
//
//*************************************************************************************************
#define UART_9BITAMASK_MASK_S 0U
#define UART_9BITAMASK_MASK_M 0xFFU // Self Address Mask for 9-Bit Mode
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPP register
//
//*************************************************************************************************
#define UART_PP_SC 0x1U // Smart Card Support
#define UART_PP_NB 0x2U // 9-Bit Support
#define UART_PP_MS 0x4U // Modem Support
#define UART_PP_MSE 0x8U // Modem Support Extended
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID4 register
//
//*************************************************************************************************
#define UART_PERIPHID4_PID4_S 0U
#define UART_PERIPHID4_PID4_M 0xFFU // UART Peripheral ID Register [7:0]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID5 register
//
//*************************************************************************************************
#define UART_PERIPHID5_PID5_S 0U
#define UART_PERIPHID5_PID5_M 0xFFU // UART Peripheral ID Register [15:8]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID6 register
//
//*************************************************************************************************
#define UART_PERIPHID6_PID6_S 0U
#define UART_PERIPHID6_PID6_M 0xFFU // UART Peripheral ID Register [23:16]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID7 register
//
//*************************************************************************************************
#define UART_PERIPHID7_PID7_S 0U
#define UART_PERIPHID7_PID7_M 0xFFU // UART Peripheral ID Register [31:24]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID0 register
//
//*************************************************************************************************
#define UART_PERIPHID0_PID0_S 0U
#define UART_PERIPHID0_PID0_M 0xFFU // UART Peripheral ID Register [7:0]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID1 register
//
//*************************************************************************************************
#define UART_PERIPHID1_PID1_S 0U
#define UART_PERIPHID1_PID1_M 0xFFU // UART Peripheral ID Register [15:8]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID2 register
//
//*************************************************************************************************
#define UART_PERIPHID2_PID2_S 0U
#define UART_PERIPHID2_PID2_M 0xFFU // UART Peripheral ID Register [23:16]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPeriphID3 register
//
//*************************************************************************************************
#define UART_PERIPHID3_PID3_S 0U
#define UART_PERIPHID3_PID3_M 0xFFU // UART Peripheral ID Register [31:24]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPCellID0 register
//
//*************************************************************************************************
#define UART_PCELLID0_CID0_S 0U
#define UART_PCELLID0_CID0_M 0xFFU // UART PrimeCell ID Register [7:0]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPCellID1 register
//
//*************************************************************************************************
#define UART_PCELLID1_CID1_S 0U
#define UART_PCELLID1_CID1_M 0xFFU // UART PrimeCell ID Register [15:8]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPCellID2 register
//
//*************************************************************************************************
#define UART_PCELLID2_CID2_S 0U
#define UART_PCELLID2_CID2_M 0xFFU // UART PrimeCell ID Register [23:16]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTPCellID3 register
//
//*************************************************************************************************
#define UART_PCELLID3_CID3_S 0U
#define UART_PCELLID3_CID3_M 0xFFU // UART PrimeCell ID Register [31:24]
//*************************************************************************************************
//
// The following are defines for the bit fields in the UARTECR register
//
//*************************************************************************************************
#define UART_ECR_DATA_S 0U
#define UART_ECR_DATA_M 0xFFU // Error Clear
#endif
@@ -0,0 +1,305 @@
//###########################################################################
//
// FILE: hw_udma.h
//
// TITLE: Definitions for the UDMA registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_UDMA_H
#define HW_UDMA_H
//*************************************************************************************************
//
// The following are defines for the UDMA register offsets
//
//*************************************************************************************************
#define UDMA_O_DMASRCENDP 0x0U // DMA Channel Source Address End Pointer
#define UDMA_O_DMADSTENDP 0x4U // DMA Channel Destination Address End Pointer
#define UDMA_O_DMACHCTL 0x8U // DMA Channel Control Word
#define UDMA_O_DMASTAT 0x0U // DMA Status
#define UDMA_O_DMACFG 0x4U // DMA Configuration
#define UDMA_O_DMACTLBASE 0x8U // DMA Channel Control Base Pointer
#define UDMA_O_DMAALTBASE 0xCU // DMA Alternate Channel Control Base Pointer
#define UDMA_O_DMASWREQ 0x14U // DMA Channel Software Request
#define UDMA_O_DMAUSEBURSTSET 0x18U // DMA Channel Useburst Set
#define UDMA_O_DMAUSEBURSTCLR 0x1CU // DMA Channel Useburst Clear
#define UDMA_O_DMAREQMASKSET 0x20U // DMA Channel Request Mask Set
#define UDMA_O_DMAREQMASKCLR 0x24U // DMA Channel Request Mask Clear
#define UDMA_O_DMAENASET 0x28U // DMA Channel Enable Set
#define UDMA_O_DMAENACLR 0x2CU // DMA Channel Enable Clear
#define UDMA_O_DMAALTSET 0x30U // DMA Channel Primary Alternate Set
#define UDMA_O_DMAALTCLR 0x34U // DMA Channel Primary Alternate Clear
#define UDMA_O_DMAPRIOSET 0x38U // DMA Channel Priority Set
#define UDMA_O_DMAPRIOCLR 0x3CU // DMA Channel Priority Clear
#define UDMA_O_DMAERRCLR 0x4CU // DMA Bus Error Clear
#define UDMA_O_DMACHMAP0 0x510U // DMA Channel Map Select 0
#define UDMA_O_DMACHMAP1 0x514U // DMA Channel Map Select 1
#define UDMA_O_DMACHMAP2 0x518U // DMA Channel Map Select 2
#define UDMA_O_DMACHMAP3 0x51CU // DMA Channel Map Select 3
#define UDMA_O_DMAPERIPHID4 0xFD0U // DMA Peripheral Identification 4
#define UDMA_O_DMAPERIPHID0 0xFE0U // DMA Peripheral Identification 0
#define UDMA_O_DMAPERIPHID1 0xFE4U // DMA Peripheral Identification 1
#define UDMA_O_DMAPERIPHID2 0xFE8U // DMA Peripheral Identification 2
#define UDMA_O_DMAPERIPHID3 0xFECU // DMA Peripheral Identification 3
#define UDMA_O_DMAPCELLID0 0xFF0U // DMA PrimeCell Identification 0
#define UDMA_O_DMAPCELLID1 0xFF4U // DMA PrimeCell Identification 1
#define UDMA_O_DMAPCELLID2 0xFF8U // DMA PrimeCell Identification 2
#define UDMA_O_DMAPCELLID3 0xFFCU // DMA PrimeCell Identification 3
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMACHCTL register
//
//*************************************************************************************************
#define UDMA_DMACHCTL_XFERMODE_S 0U
#define UDMA_DMACHCTL_XFERMODE_M 0x7U // DMA Transfer Mode
#define UDMA_DMACHCTL_NXTUSEBURST 0x8U // Next Useburst
#define UDMA_DMACHCTL_XFERSIZE_S 4U
#define UDMA_DMACHCTL_XFERSIZE_M 0x3FF0U // Transfer Size (minus 1)
#define UDMA_DMACHCTL_ARBSIZE_S 14U
#define UDMA_DMACHCTL_ARBSIZE_M 0x3C000U // Arbitration Size
#define UDMA_DMACHCTL_SRCPROT0 0x40000U // Source Privilege Access
#define UDMA_DMACHCTL_DSTPROT0 0x200000U // Destination Privilege Access
#define UDMA_DMACHCTL_SRCSIZE_S 24U
#define UDMA_DMACHCTL_SRCSIZE_M 0x3000000U // Source Data Size
#define UDMA_DMACHCTL_SRCINC_S 26U
#define UDMA_DMACHCTL_SRCINC_M 0xC000000U // Source Address Increment
#define UDMA_DMACHCTL_DSTSIZE_S 28U
#define UDMA_DMACHCTL_DSTSIZE_M 0x30000000U // Destination Data Size
#define UDMA_DMACHCTL_DSTINC_S 30U
#define UDMA_DMACHCTL_DSTINC_M 0xC0000000U // Destination Address Increment
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMASTAT register
//
//*************************************************************************************************
#define UDMA_DMASTAT_MASTEN 0x1U // Master Enable Status
#define UDMA_DMASTAT_STATE_S 4U
#define UDMA_DMASTAT_STATE_M 0xF0U // Control State Machine Status
#define UDMA_DMASTAT_DMACHANS_S 16U
#define UDMA_DMASTAT_DMACHANS_M 0x1F0000U // Available DMA Channels Minus 1
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMACFG register
//
//*************************************************************************************************
#define UDMA_DMACFG_MASTEN 0x1U // Controller Master Enable
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMACTLBASE register
//
//*************************************************************************************************
#define UDMA_DMACTLBASE_ADDR_S 10U
#define UDMA_DMACTLBASE_ADDR_M 0xFFFFFC00U // Channel Control Base Address
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAERRCLR register
//
//*************************************************************************************************
#define UDMA_DMAERRCLR_ERRCLR 0x1U // DMA Bus Error Status
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMACHMAP0 register
//
//*************************************************************************************************
#define UDMA_DMACHMAP0_CH0SEL_S 0U
#define UDMA_DMACHMAP0_CH0SEL_M 0xFU // DMA Channel 0 Source Select
#define UDMA_DMACHMAP0_CH1SEL_S 4U
#define UDMA_DMACHMAP0_CH1SEL_M 0xF0U // DMA Channel 1 Source Select
#define UDMA_DMACHMAP0_CH2SEL_S 8U
#define UDMA_DMACHMAP0_CH2SEL_M 0xF00U // DMA Channel 2 Source Select
#define UDMA_DMACHMAP0_CH3SEL_S 12U
#define UDMA_DMACHMAP0_CH3SEL_M 0xF000U // DMA Channel 3 Source Select
#define UDMA_DMACHMAP0_CH4SEL_S 16U
#define UDMA_DMACHMAP0_CH4SEL_M 0xF0000U // DMA Channel 4 Source Select
#define UDMA_DMACHMAP0_CH5SEL_S 20U
#define UDMA_DMACHMAP0_CH5SEL_M 0xF00000U // DMA Channel 5 Source Select
#define UDMA_DMACHMAP0_CH6SEL_S 24U
#define UDMA_DMACHMAP0_CH6SEL_M 0xF000000U // DMA Channel 6 Source Select
#define UDMA_DMACHMAP0_CH7SEL_S 28U
#define UDMA_DMACHMAP0_CH7SEL_M 0xF0000000U // DMA Channel 7 Source Select
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMACHMAP1 register
//
//*************************************************************************************************
#define UDMA_DMACHMAP1_CH8SEL_S 0U
#define UDMA_DMACHMAP1_CH8SEL_M 0xFU // DMA Channel 8 Source Select
#define UDMA_DMACHMAP1_CH9SEL_S 4U
#define UDMA_DMACHMAP1_CH9SEL_M 0xF0U // DMA Channel 9 Source Select
#define UDMA_DMACHMAP1_CH10SEL_S 8U
#define UDMA_DMACHMAP1_CH10SEL_M 0xF00U // DMA Channel 10 Source Select
#define UDMA_DMACHMAP1_CH11SEL_S 12U
#define UDMA_DMACHMAP1_CH11SEL_M 0xF000U // DMA Channel 11 Source Select
#define UDMA_DMACHMAP1_CH12SEL_S 16U
#define UDMA_DMACHMAP1_CH12SEL_M 0xF0000U // DMA Channel 12 Source Select
#define UDMA_DMACHMAP1_CH13SEL_S 20U
#define UDMA_DMACHMAP1_CH13SEL_M 0xF00000U // DMA Channel 13 Source Select
#define UDMA_DMACHMAP1_CH14SEL_S 24U
#define UDMA_DMACHMAP1_CH14SEL_M 0xF000000U // DMA Channel 14 Source Select
#define UDMA_DMACHMAP1_CH15SEL_S 28U
#define UDMA_DMACHMAP1_CH15SEL_M 0xF0000000U // DMA Channel 15 Source Select
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMACHMAP2 register
//
//*************************************************************************************************
#define UDMA_DMACHMAP2_CH16SEL_S 0U
#define UDMA_DMACHMAP2_CH16SEL_M 0xFU // DMA Channel 16 Source Select
#define UDMA_DMACHMAP2_CH17SEL_S 4U
#define UDMA_DMACHMAP2_CH17SEL_M 0xF0U // DMA Channel 17 Source Select
#define UDMA_DMACHMAP2_CH18SEL_S 8U
#define UDMA_DMACHMAP2_CH18SEL_M 0xF00U // DMA Channel 18 Source Select
#define UDMA_DMACHMAP2_CH19SEL_S 12U
#define UDMA_DMACHMAP2_CH19SEL_M 0xF000U // DMA Channel 19 Source Select
#define UDMA_DMACHMAP2_CH20SEL_S 16U
#define UDMA_DMACHMAP2_CH20SEL_M 0xF0000U // DMA Channel 20 Source Select
#define UDMA_DMACHMAP2_CH21SEL_S 20U
#define UDMA_DMACHMAP2_CH21SEL_M 0xF00000U // DMA Channel 21 Source Select
#define UDMA_DMACHMAP2_CH22SEL_S 24U
#define UDMA_DMACHMAP2_CH22SEL_M 0xF000000U // DMA Channel 22 Source Select
#define UDMA_DMACHMAP2_CH23SEL_S 28U
#define UDMA_DMACHMAP2_CH23SEL_M 0xF0000000U // DMA Channel 23 Source Select
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMACHMAP3 register
//
//*************************************************************************************************
#define UDMA_DMACHMAP3_CH24SEL_S 0U
#define UDMA_DMACHMAP3_CH24SEL_M 0xFU // DMA Channel 24 Source Select
#define UDMA_DMACHMAP3_CH25SEL_S 4U
#define UDMA_DMACHMAP3_CH25SEL_M 0xF0U // DMA Channel 25 Source Select
#define UDMA_DMACHMAP3_CH26SEL_S 8U
#define UDMA_DMACHMAP3_CH26SEL_M 0xF00U // DMA Channel 26 Source Select
#define UDMA_DMACHMAP3_CH27SEL_S 12U
#define UDMA_DMACHMAP3_CH27SEL_M 0xF000U // DMA Channel 27 Source Select
#define UDMA_DMACHMAP3_CH28SEL_S 16U
#define UDMA_DMACHMAP3_CH28SEL_M 0xF0000U // DMA Channel 28 Source Select
#define UDMA_DMACHMAP3_CH29SEL_S 20U
#define UDMA_DMACHMAP3_CH29SEL_M 0xF00000U // DMA Channel 29 Source Select
#define UDMA_DMACHMAP3_CH30SEL_S 24U
#define UDMA_DMACHMAP3_CH30SEL_M 0xF000000U // DMA Channel 30 Source Select
#define UDMA_DMACHMAP3_CH31SEL_S 28U
#define UDMA_DMACHMAP3_CH31SEL_M 0xF0000000U // DMA Channel 31 Source Select
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPeriphID4 register
//
//*************************************************************************************************
#define UDMA_DMAPERIPHID4_PID4_S 0U
#define UDMA_DMAPERIPHID4_PID4_M 0xFFU // DMA Peripheral ID Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPeriphID0 register
//
//*************************************************************************************************
#define UDMA_DMAPERIPHID0_PID0_S 0U
#define UDMA_DMAPERIPHID0_PID0_M 0xFFU // DMA Peripheral ID Register [7:0]
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPeriphID1 register
//
//*************************************************************************************************
#define UDMA_DMAPERIPHID1_PID1_S 0U
#define UDMA_DMAPERIPHID1_PID1_M 0xFFU // DMA Peripheral ID Register [15:8]
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPeriphID2 register
//
//*************************************************************************************************
#define UDMA_DMAPERIPHID2_PID2_S 0U
#define UDMA_DMAPERIPHID2_PID2_M 0xFFU // DMA Peripheral ID Register [23:16]
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPeriphID3 register
//
//*************************************************************************************************
#define UDMA_DMAPERIPHID3_PID3_S 0U
#define UDMA_DMAPERIPHID3_PID3_M 0xFFU // DMA Peripheral ID Register [31:24]
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPCellID0 register
//
//*************************************************************************************************
#define UDMA_DMAPCELLID0_CID0_S 0U
#define UDMA_DMAPCELLID0_CID0_M 0xFFU // DMA PrimeCell ID Register [7:0]
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPCellID1 register
//
//*************************************************************************************************
#define UDMA_DMAPCELLID1_CID1_S 0U
#define UDMA_DMAPCELLID1_CID1_M 0xFFU // DMA PrimeCell ID Register [15:8]
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPCellID2 register
//
//*************************************************************************************************
#define UDMA_DMAPCELLID2_CID2_S 0U
#define UDMA_DMAPCELLID2_CID2_M 0xFFU // DMA PrimeCell ID Register [23:16]
//*************************************************************************************************
//
// The following are defines for the bit fields in the DMAPCellID3 register
//
//*************************************************************************************************
#define UDMA_DMAPCELLID3_CID3_S 0U
#define UDMA_DMAPCELLID3_CID3_M 0xFFU // DMA PrimeCell ID Register [31:24]
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,122 @@
//###########################################################################
//
// FILE: hw_wwd.h
//
// TITLE: Definitions for the WWD registers.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef HW_WWD_H
#define HW_WWD_H
//*************************************************************************************************
//
// The following are defines for the WWD register offsets
//
//*************************************************************************************************
#define WWD_O_SCSR 0x0U // System Control & Status Register
#define WWD_O_WDCNTR 0x4U // Watchdog Counter Register
#define WWD_O_WDKEY 0x8U // Watchdog Reset Key Register
#define WWD_O_WDCR 0xCU // Watchdog Control Register
#define WWD_O_WDWCR 0x10U // Watchdog Windowed Control Register
//*************************************************************************************************
//
// The following are defines for the bit fields in the SCSR register
//
//*************************************************************************************************
#define WWD_SCSR_WDOVERRIDE 0x1U // WD Override for WDDIS bit
#define WWD_SCSR_WDENINT 0x2U // WD Interrupt Enable
#define WWD_SCSR_RSVD_S 3U
#define WWD_SCSR_RSVD_M 0xFFF8U // Reserved
#define WWD_SCSR_KEY_S 16U
#define WWD_SCSR_KEY_M 0xFFFF0000U // KEY field
//*************************************************************************************************
//
// The following are defines for the bit fields in the WDCNTR register
//
//*************************************************************************************************
#define WWD_WDCNTR_WDCNTR_S 0U
#define WWD_WDCNTR_WDCNTR_M 0xFFU // WD Counter
#define WWD_WDCNTR_RSVD_S 8U
#define WWD_WDCNTR_RSVD_M 0xFFFFFF00U // Reserved
//*************************************************************************************************
//
// The following are defines for the bit fields in the WDKEY register
//
//*************************************************************************************************
#define WWD_WDKEY_WDKEY_S 0U
#define WWD_WDKEY_WDKEY_M 0xFFU // WD KEY
#define WWD_WDKEY_RSVD_S 8U
#define WWD_WDKEY_RSVD_M 0xFFFFFF00U // Reserved
//*************************************************************************************************
//
// The following are defines for the bit fields in the WDCR register
//
//*************************************************************************************************
#define WWD_WDCR_WDPS_S 0U
#define WWD_WDCR_WDPS_M 0x7U // WD Clock Prescalar
#define WWD_WDCR_WDCHK_S 3U
#define WWD_WDCR_WDCHK_M 0x38U // WD Check Bits
#define WWD_WDCR_WDDIS 0x40U // WD Disable
#define WWD_WDCR_WDFLG 0x80U // WD Reset Status Flag
#define WWD_WDCR_WDPRECLKDIV_S 8U
#define WWD_WDCR_WDPRECLKDIV_M 0xF00U // WD Pre Clock Divider
#define WWD_WDCR_RSVD_S 12U
#define WWD_WDCR_RSVD_M 0xFFFFF000U // Reserved
//*************************************************************************************************
//
// The following are defines for the bit fields in the WDWCR register
//
//*************************************************************************************************
#define WWD_WDWCR_MIN_S 0U
#define WWD_WDWCR_MIN_M 0xFFU // WD Min Threshold setting for Windowed Watchdog
// functionality
#define WWD_WDWCR_FIRSTKEY 0x100U // First Key Detect Flag
#define WWD_WDWCR_RSVD_S 9U
#define WWD_WDWCR_RSVD_M 0xFE00U // Reserved
#define WWD_WDWCR_KEY_S 16U
#define WWD_WDWCR_KEY_M 0xFFFF0000U // KEY field
#endif
@@ -0,0 +1,96 @@
/* =============================================================================
* Copyright (c) Texas Instruments Incorporated 2012-2015
*
* 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.
*/
/**
* \file stw_dataTypes.h
*
* \brief Starterware header file containing standard data types.
*
*/
#ifndef STW_DATATYPES_H_
#define STW_DATATYPES_H_
/* ========================================================================== */
/* Include Files */
/* ========================================================================== */
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ========================================================================== */
/* Macros & Typedefs */
/* ========================================================================== */
typedef uint16_t Bool; /* In sync with xdc/std.h */
typedef uint32_t UInt32;
typedef int32_t Int32;
typedef uint16_t UInt16;
typedef int16_t Int16;
typedef uint8_t UInt8;
typedef int8_t Int8;
typedef char Char;
typedef void * Ptr;
typedef uint32_t UArg;
typedef double Double;
typedef uint64_t UInt64;
typedef unsigned char tBoolean;
typedef float Float32;
/* To fix Misra-C errors */
#ifndef TRUE
#define TRUE ((Bool) 1)
#endif
#ifndef FALSE
#define FALSE ((Bool) 0)
#endif
/* ========================================================================== */
/* Structure Declarations */
/* ========================================================================== */
/* None */
/* ========================================================================== */
/* Function Declarations */
/* ========================================================================== */
/* None */
#ifdef __cplusplus
}
#endif
#endif /* #ifndef STW_DATATYPES_H_ */
@@ -0,0 +1,111 @@
/* =============================================================================
* Copyright (c) Texas Instruments Incorporated 2014-2015
*
* 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.
*/
/**
* \file stw_types.h
*
* \brief This file contains the data types and macros commonly used in
* Starterware.
*/
#ifndef STW_TYPES_H_
#define STW_TYPES_H_
/* ========================================================================== */
/* Include Files */
/* ========================================================================== */
/* None */
#ifdef __cplusplus
extern "C" {
#endif
/* ========================================================================== */
/* Macros & Typedefs */
/* ========================================================================== */
/**
* \brief This macro defines the Boolean that is used for True.
*/
#define SUCCESS ((uint32_t) 1U)
/**
* \brief This macro defines the Boolean that is used for False.
*/
#define FAIL ((uint32_t) 0U)
#define INVALID_PARAM (-((int32_t) 1))
/*
* =========== Error codes returned by STW functions ===========
*/
#define STW_SOK ((int32_t) 0)
#define STW_EFAIL (-((int32_t) 1))
#define STW_EBADARGS (-((int32_t) 2))
#define STW_EINVALID_PARAMS (-((int32_t) 3))
#define STW_ETIMEOUT (-((int32_t) 4))
#define STW_EOUT_OF_RANGE (-((int32_t) 5))
#define STW_EUNSUPPORTED_CMD (-((int32_t) 6))
#define STW_EUNSUPPORTED_OPS (-((int32_t) 7))
/* ========================================================================== */
/* Structures and Enums */
/* ========================================================================== */
/* None */
/* ========================================================================== */
/* Internal Function Declarations */
/* ========================================================================== */
/* None */
/* ========================================================================== */
/* Global Variables */
/* ========================================================================== */
/* None */
/* ========================================================================== */
/* Function Declarations */
/* ========================================================================== */
/* None */
#ifdef __cplusplus
}
#endif
#endif
@@ -0,0 +1,528 @@
//###########################################################################
//
// FILE: interrupt.c
//
// TITLE: Driver for the NVIC Interrupt Controller.
//
//###########################################################################
//
// 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 "interrupt.h"
//*****************************************************************************
//
// RAM Vector Table to be used as srcVectorTable in
// Interrupt_initRAMVectorTable(). Set the size of the vector table to the
// largest number of interrupts of any device.
//
//*****************************************************************************
#ifndef USE_RTOS
#pragma DATA_ALIGN(vectorTableRAM, 1024U)
#pragma DATA_SECTION(vectorTableRAM, ".vtable")
#pragma WEAK(vectorTableRAM)
void (*vectorTableRAM[NUM_INTERRUPTS])(void);
#endif
//*****************************************************************************
//
// Interrupt_enable()
//
//*****************************************************************************
void
Interrupt_enable(uint32_t interruptNum)
{
//
// Check the arguments.
//
ASSERT(interruptNum < NUM_INTERRUPTS);
//
// Enable the interrupt.
//
if(interruptNum == FAULT_MPU)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) |= NVIC_SHCSRS_MEMFAULTENA;
}
else if(interruptNum == FAULT_BUS)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) |= NVIC_SHCSRS_BUSFAULTENA;
}
else if(interruptNum == FAULT_USAGE)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) |= NVIC_SHCSRS_USGFAULTENA;
}
else if(interruptNum == FAULT_SYSTICK)
{
HWREG(NVIC_BASE + NVIC_O_SYST_CSR) |= NVIC_SYST_CSR_TICKINT;
}
else if(interruptNum >= 16U)
{
HWREG(NVIC_BASE + NVIC_O_ISER0 +
(NVIC_OFFSET_INC * ((interruptNum - 16U) / 32U))) =
(uint32_t)1U << ((interruptNum - 16U) & 0x1FU);
}
else
{
//
// Do Nothing.
//
}
}
//*****************************************************************************
//
// Interrupt_disable()
//
//*****************************************************************************
void
Interrupt_disable(uint32_t interruptNum)
{
//
// Check the arguments.
//
ASSERT(interruptNum <= NUM_INTERRUPTS);
//
// Disable the interrupt.
//
if(interruptNum == FAULT_MPU)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) &= ~NVIC_SHCSRS_MEMFAULTENA;
}
else if(interruptNum == FAULT_BUS)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) &= ~NVIC_SHCSRS_BUSFAULTENA;
}
else if(interruptNum == FAULT_USAGE)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) &= ~NVIC_SHCSRS_USGFAULTENA;
}
else if(interruptNum == FAULT_SYSTICK)
{
HWREG(NVIC_BASE + NVIC_O_SYST_CSR) &= ~NVIC_SYST_CSR_TICKINT;
}
else if(interruptNum >= 16U)
{
HWREG(NVIC_BASE + NVIC_O_ICER0 +
(NVIC_OFFSET_INC * ((interruptNum - 16U) / 32U))) =
(uint32_t)1U << ((interruptNum - 16U) & 0x1FU);
}
else
{
//
// Do Nothing.
//
}
}
//*****************************************************************************
//
// Interrupt_isEnabled()
//
//*****************************************************************************
bool
Interrupt_isEnabled(uint32_t interruptNum)
{
uint32_t status;
//
// Check the arguments.
//
ASSERT(interruptNum <= NUM_INTERRUPTS);
//
// Return the interrupt status
//
if(interruptNum == FAULT_MPU)
{
status = HWREG(NVIC_BASE + NVIC_O_SHCSRS) & NVIC_SHCSRS_MEMFAULTENA;
}
else if(interruptNum == FAULT_BUS)
{
status = HWREG(NVIC_BASE + NVIC_O_SHCSRS) & NVIC_SHCSRS_BUSFAULTENA;
}
else if(interruptNum == FAULT_USAGE)
{
status = HWREG(NVIC_BASE + NVIC_O_SHCSRS) & NVIC_SHCSRS_USGFAULTENA;
}
else if(interruptNum == FAULT_SYSTICK)
{
status = HWREG(NVIC_BASE + NVIC_O_SYST_CSR) & NVIC_SYST_CSR_TICKINT;
}
else if(interruptNum >= 16U)
{
status = HWREG(NVIC_BASE + (uint32_t)NVIC_O_ISER0 +
(NVIC_OFFSET_INC * ((interruptNum - 16U) / 32U))) &
(1U << ((interruptNum - 16U) & 0x1FU));
}
else
{
status = 0U;
}
//
// Return peripheral interrupt status.
//
return(status != 0U);
}
//*****************************************************************************
//
// Interrupt_pend()
//
//*****************************************************************************
void
Interrupt_pend(uint32_t interruptNum)
{
//
// Check the arguments.
//
ASSERT(interruptNum <= NUM_INTERRUPTS);
//
// Pends the corresponding channel interrupt.
//
if(interruptNum == FAULT_NMI)
{
HWREG(NVIC_BASE + NVIC_O_ICSR) |= NVIC_ICSR_NMIPENDSET;
}
else if(interruptNum == FAULT_PENDSV)
{
HWREG(NVIC_BASE + NVIC_O_ICSR) |= NVIC_ICSR_PENDSVSET;
}
else if(interruptNum == FAULT_SYSTICK)
{
HWREG(NVIC_BASE + NVIC_O_ICSR) |= NVIC_ICSR_PENDSTSET;
}
else if(interruptNum == FAULT_SVCALL)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) |= NVIC_SHCSRS_SVCALLPENDED;
}
else if(interruptNum == FAULT_BUS)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) |= NVIC_SHCSRS_BUSFAULTPENDED;
}
else if(interruptNum == FAULT_MPU)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) |= NVIC_SHCSRS_MEMFAULTPENDED;
}
else if(interruptNum == FAULT_USAGE)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) |= NVIC_SHCSRS_USGFAULTPENDED;
}
else if(interruptNum >= 16U)
{
HWREG(NVIC_BASE + NVIC_O_ISPR0 +
(NVIC_OFFSET_INC * ((interruptNum - 16U) / 32U))) =
(uint32_t)1U << ((interruptNum - 16U) & 0x1FU);
}
else
{
//
// Do Nothing.
//
}
}
//*****************************************************************************
//
// Interrupt_unpend()
//
//*****************************************************************************
void
Interrupt_unpend(uint32_t interruptNum)
{
//
// Check the arguments.
//
ASSERT(interruptNum <= NUM_INTERRUPTS);
//
// Unpends the corresponding channel interrupt.
//
if(interruptNum == FAULT_PENDSV)
{
HWREG(NVIC_BASE + NVIC_O_ICSR) |= NVIC_ICSR_PENDSVCLR;
}
else if(interruptNum == FAULT_SYSTICK)
{
HWREG(NVIC_BASE + NVIC_O_ICSR) |= NVIC_ICSR_PENDSTCLR;
}
else if(interruptNum == FAULT_SVCALL)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) &= ~NVIC_SHCSRS_SVCALLPENDED;
}
else if(interruptNum == FAULT_BUS)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) &= ~NVIC_SHCSRS_BUSFAULTPENDED;
}
else if(interruptNum == FAULT_MPU)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) &= ~NVIC_SHCSRS_MEMFAULTPENDED;
}
else if(interruptNum == FAULT_USAGE)
{
HWREG(NVIC_BASE + NVIC_O_SHCSRS) &= ~NVIC_SHCSRS_USGFAULTPENDED;
}
else if(interruptNum >= 16U)
{
HWREG(NVIC_BASE + NVIC_O_ICPR0 +
(NVIC_OFFSET_INC * ((interruptNum - 16U) / 32U))) =
(uint32_t)1U << ((interruptNum - 16U) & (uint32_t)0x1FU);
}
else
{
//
// Do Nothing.
//
}
}
//*****************************************************************************
//
// Interrupt_setPriority()
//
//*****************************************************************************
void
Interrupt_setPriority(uint32_t interruptNum, uint32_t priority)
{
uint32_t offset, shift, mask;
//
// Check the arguments.
//
ASSERT((interruptNum >= 4U) && (interruptNum < NUM_INTERRUPTS));
//
// Set the interrupt priority.
//
if(interruptNum == FAULT_MPU)
{
HWREG(NVIC_BASE + NVIC_O_SHPR1) = (HWREG(NVIC_BASE + NVIC_O_SHPR1) &
~(uint32_t)NVIC_SHPR1_PRI_4_M) |
(priority << NVIC_SHPR1_PRI_4_S);
}
else if(interruptNum == FAULT_BUS)
{
HWREG(NVIC_BASE + NVIC_O_SHPR1) = (HWREG(NVIC_BASE + NVIC_O_SHPR1) &
~(uint32_t)NVIC_SHPR1_PRI_5_M) |
(priority << NVIC_SHPR1_PRI_5_S);
}
else if(interruptNum == FAULT_USAGE)
{
HWREG(NVIC_BASE + NVIC_O_SHPR1) = (HWREG(NVIC_BASE + NVIC_O_SHPR1) &
~(uint32_t)NVIC_SHPR1_PRI_6_M) |
(priority << NVIC_SHPR1_PRI_6_S);
}
else if(interruptNum == FAULT_SVCALL)
{
HWREG(NVIC_BASE + NVIC_O_SHPR2) = (HWREG(NVIC_BASE + NVIC_O_SHPR2) &
~(uint32_t)NVIC_SHPR2_PRI_11_M) |
(priority << NVIC_SHPR2_PRI_11_S);
}
else if(interruptNum == FAULT_PENDSV)
{
HWREG(NVIC_BASE + NVIC_O_SHPR3) = (HWREG(NVIC_BASE + NVIC_O_SHPR3) &
~(uint32_t)NVIC_SHPR3_PRI_14_M) |
(priority << NVIC_SHPR3_PRI_14_S);
}
else if(interruptNum == FAULT_SYSTICK)
{
HWREG(NVIC_BASE + NVIC_O_SHPR3) = (HWREG(NVIC_BASE + NVIC_O_SHPR3) &
~(uint32_t)NVIC_SHPR3_PRI_15_M) |
(priority << NVIC_SHPR3_PRI_15_S);
}
else if(interruptNum >= 16U)
{
offset = (uint32_t)NVIC_OFFSET_INC * ((interruptNum - 16U) / 4U);
shift = ((uint32_t)8U * (interruptNum & 0x3U)) + NVIC_IPR0_PRI_0_S;
mask = (uint32_t)NVIC_IPR0_PRI_0_M << (8U * (interruptNum & 0x3U));
HWREG(NVIC_BASE + NVIC_O_IPR0 + offset) =
(HWREG(NVIC_BASE + (uint32_t)NVIC_O_IPR0 + offset) & ~mask) |
(priority << shift);
}
else
{
//
// Do Nothing.
//
}
}
//*****************************************************************************
//
// Interrupt_getPriority()
//
//*****************************************************************************
uint32_t
Interrupt_getPriority(uint32_t interruptNum)
{
uint32_t offset, shift, status;
//
// Check the arguments.
//
ASSERT((interruptNum >= 4U) && (interruptNum < NUM_INTERRUPTS));
//
// Set the interrupt priority.
//
if(interruptNum == FAULT_MPU)
{
status = (HWREG(NVIC_BASE + NVIC_O_SHPR1) & NVIC_SHPR1_PRI_4_M) >>
NVIC_SHPR1_PRI_4_S;
}
else if(interruptNum == FAULT_BUS)
{
status = (HWREG(NVIC_BASE + NVIC_O_SHPR1) & NVIC_SHPR1_PRI_5_M) >>
NVIC_SHPR1_PRI_5_S;
}
else if(interruptNum == FAULT_USAGE)
{
status = (HWREG(NVIC_BASE + NVIC_O_SHPR1) & NVIC_SHPR1_PRI_6_M) >>
NVIC_SHPR1_PRI_6_S;
}
else if(interruptNum == FAULT_SVCALL)
{
status = (HWREG(NVIC_BASE + NVIC_O_SHPR2) & NVIC_SHPR2_PRI_11_M) >>
NVIC_SHPR2_PRI_11_S;
}
else if(interruptNum == FAULT_PENDSV)
{
status = (HWREG(NVIC_BASE + NVIC_O_SHPR3) & NVIC_SHPR3_PRI_14_M) >>
NVIC_SHPR3_PRI_14_S;
}
else if(interruptNum == FAULT_SYSTICK)
{
status = (HWREG(NVIC_BASE + NVIC_O_SHPR3) & NVIC_SHPR3_PRI_15_M) >>
NVIC_SHPR3_PRI_15_S;
}
else if(interruptNum >= 16U)
{
offset = (uint32_t)NVIC_OFFSET_INC * ((interruptNum - 16U) / 4U);
shift = ((uint32_t)8U * (interruptNum & 0x3U)) + 5U;
status = (HWREG(NVIC_BASE + (uint32_t)NVIC_O_IPR0 + offset) >> shift) &
0xFFU;
}
else
{
status = 0U;
}
return(status);
}
//*****************************************************************************
//
// Interrupt_initRAMVectorTable()
//
//*****************************************************************************
void
Interrupt_initRAMVectorTable(void (*srcVectorTable[])(void),
void (*dstVectorTable[])(void))
{
uint32_t index;
//
// Check whether dstVectorTable lies in RAM and is correctly aligned.
//
ASSERT((uint32_t)dstVectorTable >= 0x20000000U);
ASSERT(((uint32_t)dstVectorTable & 0x000003FFU) == 0U);
if(HWREG(NVIC_BASE + NVIC_O_VTOR) != (uint32_t)dstVectorTable)
{
//
// Point the NVIC at the RAM vector table.
//
HWREG(NVIC_BASE + NVIC_O_VTOR) = (uint32_t)dstVectorTable;
}
//
// Copy the ISRs from temp vector table to RAM vector table.
//
for(index = 0U; index < NUM_INTERRUPTS; index++)
{
dstVectorTable[index] = srcVectorTable[index];
}
}
//*****************************************************************************
//
// Interrupt_registerHandler()
//
//*****************************************************************************
void
Interrupt_registerHandler(uint32_t interruptNum, void (*intHandler)(void))
{
uint32_t index, value;
//
// Check the arguments.
//
ASSERT(interruptNum < NUM_INTERRUPTS);
//
// Make sure that the RAM vector table is correctly aligned.
// Check vector table alignment in device datasheet.
//
ASSERT(((uint32_t)vectorTableRAM & 0x000003FFU) == 0U);
//
// See if the RAM vector table has been initialized.
//
if(HWREG(NVIC_BASE + NVIC_O_VTOR) != (uint32_t)vectorTableRAM)
{
//
// Copy the vector table from the beginning of FLASH to the RAM vector
// table.
//
value = HWREG(NVIC_BASE + NVIC_O_VTOR);
for(index = 0U; index < NUM_INTERRUPTS; index++)
{
vectorTableRAM[index] = (void (*)(void))HWREG((index * 4U) + value);
}
//
// Point the NVIC at the RAM vector table.
//
HWREG(NVIC_BASE + NVIC_O_VTOR) = (uint32_t)vectorTableRAM;
}
//
// Save the interrupt handler.
//
vectorTableRAM[interruptNum] = intHandler;
}
@@ -0,0 +1,676 @@
//###########################################################################
//
// FILE: interrupt.h
//
// TITLE: Driver for the NVIC Interrupt Controller.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef INTERRUPT_H
#define INTERRUPT_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup interrupt_api INTERRUPT
//! \brief This module configures the NVIC interrupt controller.
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "cpu.h"
#include "debug.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
#ifndef DOXYGEN_PDF_IGNORE
//*****************************************************************************
//
// Defines for the API.
//
//*****************************************************************************
//*****************************************************************************
//
// Defines for specifying NVIC module register offset increment.
//
//*****************************************************************************
#define NVIC_OFFSET_INC 0x4U //!< 8-bit offset increment
//*****************************************************************************
//
// Define for specifying the key for AIRCR register.
//
//*****************************************************************************
#define NVIC_AIRCR_VECTKEY 0x05FA0000U
//*****************************************************************************
//
// Flash Vector Table defined in startup.ccs.
//
//*****************************************************************************
#ifndef USE_RTOS
extern void (*vectorTableFlash[NUM_INTERRUPTS])(void);
#endif
//*****************************************************************************
//
// RAM Vector Table to be used as dstVectorTable in
// Interrupt_initRAMVectorTable(). Set the size of the vector table to the
// largest number of interrupts of any device.
//
//*****************************************************************************
#ifndef USE_RTOS
extern void (*vectorTableRAM[NUM_INTERRUPTS])(void);
#endif
#endif
//*****************************************************************************
//
//! Values that can be passed to Interrupt_setPriorityGrouping() as priGroup
//! parameter.
//
//*****************************************************************************
typedef enum
{
Interrupt_PriorityGrouping_7_1 = 0x00000000U, //!<Priority group 7.1 split
Interrupt_PriorityGrouping_6_2 = 0x00000100U, //!<Priority group 6.2 split
Interrupt_PriorityGrouping_5_3 = 0x00000200U, //!<Priority group 5.3 split
Interrupt_PriorityGrouping_4_4 = 0x00000300U, //!<Priority group 4.4 split
Interrupt_PriorityGrouping_3_5 = 0x00000400U, //!<Priority group 3.5 split
Interrupt_PriorityGrouping_2_6 = 0x00000500U, //!<Priority group 2.6 split
Interrupt_PriorityGrouping_1_7 = 0x00000600U, //!<Priority group 1.7 split
Interrupt_PriorityGrouping_0_8 = 0x00000700U //!<Priority group 0.8 split
} Interrupt_PriorityGrouping;
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! \internal
//! The default interrupt handler.
//!
//! This is the default interrupt handler for all interrupts. It simply loops
//! forever so that the system state is preserved for observation by a
//! debugger. Since interrupts must be disabled before unregistering the
//! corresponding handler, this should never be called during normal operation.
//!
//! \return None.
//
//*****************************************************************************
#ifndef USE_RTOS
static inline void
Interrupt_defaultHandler(void)
{
//
// Go into an infinite loop.
//
while((bool)true)
{
}
}
#endif
//*****************************************************************************
//
//! Enables the processor interrupt.
//!
//! This function allows the processor to respond to interrupts. This function
//! does not affect the set of interrupts enabled in the interrupt controller,
//! it just gates the single interrupt from the controller to the processor.
//!
//! \return Returns \b true if interrupts were disabled when the function was
//! called or \b false if they were initially enabled.
//
//*****************************************************************************
static inline bool
Interrupt_enableInProcessor(void)
{
//
// Enable processor interrupts.
//
return(CPU_clearPRIMASK() == 0x1UL);
}
//*****************************************************************************
//
//! Disables the processor interrupt.
//!
//! This function prevents the processor from receiving interrupts. This
//! function does not affect the set of interrupts enabled in the interrupt
//! controller; it just gates the single interrupt from the controller to the
//! processor.
//!
//! \return Returns \b true if interrupts were already disabled when the
//! function was called or \b false if they were initially enabled.
//
//*****************************************************************************
static inline bool
Interrupt_disableInProcessor(void)
{
//
// Disable processor interrupts.
//
return(CPU_setPRIMASK() == 0x1UL);
}
//*****************************************************************************
//
//! Triggers an interrupt.
//!
//! \param interruptNum specifies the interrupt to be triggered.
//!
//! This function performs a software trigger of an interrupt.The interrupt
//! controller behaves as if the corresponding interrupt line was asserted,
//! and the interrupt is handled in the same manner (meaning that it must be
//! enabled in order to be processed, and the processing is based on its
//! priority with respect to other unhandled interrupts).
//!
//! \return None.
//
//*****************************************************************************
static inline void
Interrupt_setSoftwareTrigger(uint32_t interruptNum)
{
//
// Check the arguments.
//
ASSERT((interruptNum >= 16U) && (interruptNum < NUM_INTERRUPTS));
//
// Trigger this interrupt.
//
HWREG(NVIC_BASE + NVIC_O_STIR) = interruptNum - 16U;
}
//*****************************************************************************
//
//! Sets the offset address of the vector table.
//!
//! \param addr is the new address of the vector table.
//!
//! Sets the address of the vector table. This function is for advanced users
//! who might want to switch between multiple instances of vector tables
//! (perhaps between flash/ram). The param addr can take following values:
//! (uint32_t)vectorTableFlash - Offset address for Flash Vector Table
//! (uint32_t)vectorTableRAM - Offset address for RAM Vector Table
//!
//! \return None.
//
//*****************************************************************************
static inline void
Interrupt_setVectorTableOffset(uint32_t addr)
{
HWREG(NVIC_BASE + NVIC_O_VTOR) = addr;
}
//*****************************************************************************
//
//! Returns the offset address of the interrupt vector table.
//!
//! This function returns the offset address of the interrupt vector table.
//!
//! \return Offset address of the vector table.
//
//*****************************************************************************
static inline uint32_t
Interrupt_getVectorTableOffset(void)
{
return(HWREG(NVIC_BASE + NVIC_O_VTOR));
}
//*****************************************************************************
//
//! Sets the priority grouping of the interrupt controller.
//!
//! \param priGrouping specifies the required priority grouping
//!
//! This function specifies the split between preemptable priority levels and
//! sub-priority levels in the interrupt priority specification. The range of
//! the grouping values are dependent upon the hardware implementation; on
//! the MSP432 family, three bits are available for hardware interrupt
//! prioritization and therefore priority grouping values of three through
//! seven have the same effect.
//!
//! \return None.
//
//*****************************************************************************
static inline void
Interrupt_setPriorityGrouping(Interrupt_PriorityGrouping priGrouping)
{
//
// Check the arguments.
//
ASSERT(priGrouping < NUM_PRIORITY);
//
// Set the priority grouping.
//
HWREG(NVIC_BASE + NVIC_O_AIRCR) = NVIC_AIRCR_VECTKEY |
(uint32_t)priGrouping;
}
//*****************************************************************************
//
//! Gets the priority grouping of the interrupt controller.
//!
//! This function returns the split between preemptable priority levels and
//! sub-priority levels in the interrupt priority specification.
//!
//! \return The number of bits of preemptable priority.
//
//*****************************************************************************
static inline uint32_t
Interrupt_getPriorityGrouping(void)
{
//
// Read the priority grouping.
//
return(HWREG(NVIC_BASE + NVIC_O_AIRCR) & NVIC_AIRCR_PRIGROUP_M);
}
//*****************************************************************************
//! Resets the core and all on-chip peripherals except Debug interface.
//!
//! This function will perform a software reset of the entire device. The
//! processor and all peripherals will be reset and all device registers will
//! return to their default values (with the exception of the reset cause
//! register, which will maintain its current value but have the software reset
//! bit set as well).
//!
//! \return None
//*****************************************************************************
static inline void
Interrupt_requestSystemReset(void)
{
//
// Perform a software reset request. This will cause the device to reset,
// no further code will be executed.
//
HWREG(NVIC_BASE + NVIC_O_AIRCR) = NVIC_AIRCR_VECTKEY |
NVIC_AIRCR_SYSRESETREQ;
//
// The device should have reset, so this should never be reached. Just in
// case, loop forever.
//
while((bool)true)
{
}
}
//*****************************************************************************
//
//! Sets the priority masking level.
//!
//! \param priorityMask is the priority level that is masked.
//!
//! This function sets the interrupt priority masking level so that all
//! interrupts at the specified or lesser priority level are masked. Masking
//! interrupts can be used to globally disable a set of interrupts with
//! priority below a predetermined threshold. A value of 0 disables priority
//! masking.
//!
//! Smaller numbers correspond to higher interrupt priorities. So for example
//! a priority level mask of 4 allows interrupts of priority level 0-3,
//! and interrupts with a numerical priority of 4 and greater are blocked.
//!
//! \return None.
//
//*****************************************************************************
static inline void
Interrupt_setPriorityMask(uint32_t priorityMask)
{
//
// Set the priority mask.
//
CPU_setBASEPRI(priorityMask);
}
//*****************************************************************************
//
//! Gets the priority masking level.
//!
//! This function gets the current setting of the interrupt priority masking
//! level. The value returned is the priority level such that all interrupts
//! of that and lesser priority are masked. A value of 0 means that priority
//! masking is disabled.
//!
//! Smaller numbers correspond to higher interrupt priorities. So for example
//! a priority level mask of 4 allows interrupts of priority level 0-3,
//! and interrupts with a numerical priority of 4 and greater are blocked.
//!
//! \return Returns the value of the interrupt priority level mask.
//
//*****************************************************************************
static inline uint32_t
Interrupt_getPriorityMask(void)
{
//
// Return the current priority mask.
//
return((uint32_t)CPU_getBASEPRI());
}
//*****************************************************************************
//
//! Enables the processor to sleep when exiting an ISR.
//!
//! This function enables the processor to sleep when exiting an ISR. For low
//! power operation, this is ideal as power cycles are not wasted with the
//! processing required for waking up from an ISR and going back to sleep.
//!
//! \return None
//
//*****************************************************************************
static inline void
Interrupt_enableSleepOnISRExit(void)
{
HWREG(NVIC_BASE + NVIC_O_SCR) |= NVIC_SCR_SLEEPONEXIT;
}
//*****************************************************************************
//
//! Disables the processor to sleep when exiting an ISR.
//!
//! This function disables the processor to sleep when exiting an ISR.
//!
//! \return None
//
//*****************************************************************************
static inline void
Interrupt_disableSleepOnISRExit(void)
{
HWREG(NVIC_BASE + NVIC_O_SCR) &= ~NVIC_SCR_SLEEPONEXIT;
}
//*****************************************************************************
//
//! Unregisters the function to be called when an interrupt occurs.
//!
//! This function is used to indicate that no handler should be called when the
//! given interrupt is asserted to the processor. The interrupt source is
//! automatically disabled (via Interrupt_disableInterrupt()) if necessary.
//!
//! \sa Interrupt_registerInterrupt() for important information about
//! registering interrupt handlers.
//!
//! See \link Interrupt_enable() \endlink for details about the interrupt
//! parameter
//!
//! \return None.
//
//*****************************************************************************
static inline void
Interrupt_unregisterHandler(uint32_t interruptNum)
{
//
// Check the arguments.
//
ASSERT(interruptNum < NUM_INTERRUPTS);
//
// Reset the interrupt handler.
//
vectorTableRAM[interruptNum] = Interrupt_defaultHandler;
}
//*****************************************************************************
//
//! Registers a function to be called when an interrupt occurs.
//!
//! \param interruptNum specifies the interrupt in question.
//! \param intHandler is a pointer to the function to be called.
//!
//! \note The use of this function (directly or indirectly via a peripheral
//! driver interrupt register function) moves the interrupt vector table from
//! flash to SRAM. Therefore, care must be taken when linking the application
//! to ensure that the SRAM vector table is located at the beginning of SRAM,
//! otherwise the NVIC does not look in the correct portion of memory for the
//! vector table (it requires the vector table be on a 1 kB memory alignment).
//! Normally, the SRAM vector table is so placed via the use of linker scripts.
//! See the discussion of compile-time versus run-time interrupt handler
//! registration in the introduction to this chapter.
//!
//! \note This function is only used if the customer wants to specify the
//! interrupt handler at run time. In most cases, this is done through means
//! of the user setting the ISR function pointer in the startup file. Refer
//! Refer to the Module Operation section for more details.
//!
//! See \link Interrupt_enable() \endlink for details about the interrupt
//! parameter
//!
//! \return None.
//
//*****************************************************************************
extern void
Interrupt_registerHandler(uint32_t interruptNum, void (*intHandler)(void));
//*****************************************************************************
//
//! Enables an interrupt in interrupt controller.
//!
//! \param interruptNum is the interrupt to be enabled.
//!
//! This function enables the specified interrupt in the interrupt controller.
//! The parameter interruptNum can take any of the valid interrupts from
//! hw_ints.h file. Other enables for the interrupt (such as at the peripheral
//! level) are unaffected by this function.
//!
//! \return None.
//
//*****************************************************************************
extern void
Interrupt_enable(uint32_t interruptNum);
//*****************************************************************************
//
//! Disables an interrupt in interrupt controller.
//!
//! \param interruptNum is the interrupt to be disabled.
//!
//! This function disables the specified interrupt in the interrupt controller.
//! The parameter interruptNum can take any of the valid interrupts from
//! hw_ints.h file. Other enables for the interrupt (such as at the peripheral
//! level) are unaffected by this function.
//!
//! \return None.
//
//*****************************************************************************
extern void
Interrupt_disable(uint32_t interruptNum);
//*****************************************************************************
//
//! Returns if a peripheral interrupt is enabled.
//!
//! \param interruptNum is the interrupt to be checked.
//!
//! This function checks if the specified interrupt is enabled in the interrupt
//! controller. The \e interruptNum parameter must be one of the valid
//! interrupts defined in the inc/hw_ints.h header file.
//!
//! \return None.
//
//*****************************************************************************
extern bool
Interrupt_isEnabled(uint32_t interruptNum);
//*****************************************************************************
//
//! Pends an interrupt.
//!
//! \param interruptNum specifies the interrupt to be pended.
//!
//! The specified interrupt is pended in the interrupt controller. Pending an
//! interrupt causes the interrupt controller to execute the corresponding
//! interrupt handler at the next available time, based on the current
//! interrupt state priorities. For example, if called by a higher priority
//! interrupt handler, the specified interrupt handler is not called until
//! after the current interrupt handler has completed execution. The interrupt
//! must have been enabled for it to be called.
//!
//! See \link Interrupt_enable() \endlink for details about the
//! interrupt parameter
//!
//! \return None.
//
//*****************************************************************************
extern void
Interrupt_pend(uint32_t interruptNum);
//*****************************************************************************
//
//! Un-pends an interrupt.
//!
//! \param interruptNum specifies the interrupt to be un-pended.
//!
//! The specified interrupt is un-pended in the interrupt controller. This
//! will cause any previously generated interrupts that have not been handled
//! yet (due to higher priority interrupts or the interrupt no having been
//! enabled yet) to be discarded.
//!
//! See \link Interrupt_enable() \endlink for details about the interrupt
//! parameter
//!
//! \return None.
//
//*****************************************************************************
extern void
Interrupt_unpend(uint32_t interruptNum);
//*****************************************************************************
//
//! Sets the priority of an interrupt.
//!
//! \param interruptNum specifies the interrupt in question.
//! \param priority specifies the priority of the interrupt.
//!
//! This function is used to set the priority of an interrupt. When multiple
//! interrupts are asserted simultaneously, the ones with the highest priority
//! are processed before the lower priority interrupts. Smaller numbers
//! correspond to higher interrupt priorities; priority 0 is the highest
//! interrupt priority.
//!
//! The hardware priority mechanism only looks at the upper N bits of the
//! priority level, so any prioritization must be performed in those bits.
//! The remaining bits can be used to sub-prioritize the interrupt sources,
//! and may be used by the hardware priority mechanism on a future part. This
//! arrangement allows priorities to migrate to different NVIC implementations
//! without changing the gross prioritization of the interrupts.
//!
//! See \link Interrupt_enable() \endlink for details about the interrupt
//! parameter
//!
//! \return None.
//
//*****************************************************************************
extern void
Interrupt_setPriority(uint32_t interruptNum, uint32_t priority);
//*****************************************************************************
//
//! Gets the priority of an interrupt.
//!
//! \param interruptNum specifies the interrupt in question.
//!
//! This function gets the priority of an interrupt. See
//! Interrupt_setPriority() for a definition of the priority value.
//!
//! See \link Interrupt_enable() \endlink for details about the interrupt
//! parameter
//!
//! \return Returns the interrupt priority, or -1 if an invalid interrupt was
//! specified.
//
//*****************************************************************************
extern uint32_t
Interrupt_getPriority(uint32_t interruptNum);
//*****************************************************************************
//
//! Initializes all the ISRs in the RAM vector table.
//!
//! \param srcVectorTable is source vector table array
//! \param dstVectorTable is destination vector table array
//!
//! This function initializes all the ISRs in the RAM vector table. It copies
//! the ISR addresses from temporary source table to destination RAM vector
//! table. The \e srcVectorTable can be preinitialised table which can be used
//! to initialize vector table in one go. \e dstVectorTable can be the RAM
//! vector table to be populated.
//!
//! \return None
//
//*****************************************************************************
extern void
Interrupt_initRAMVectorTable(void (*srcVectorTable[])(void),
void (*dstVectorTable[])(void));
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // INTERRUPT_H
@@ -0,0 +1,450 @@
//###########################################################################
//
// FILE: ipc.c
//
// TITLE: CM IPC driver.
//
//###########################################################################
//
// 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 "ipc.h"
//
// Macros internal to the IPC driver
//
#define IPC_REG_BOOTSTS_OFFSET 0x40U
#define IPC_ADDR_OFFSET_NOCHANGE 2U
#define IPC_ADDR_OFFSET_MUL2 4U
#define IPC_ADDR_OFFSET_DIV2 1U
#define IPC_ADDR_OFFSET_CORR(addr, corr) (((addr) * (corr)) / 2U)
#if IPC_MSGQ_SUPPORT == 1U
//
// Global Circular Buffer Definitions
//
#pragma DATA_SECTION(IPC_CM_To_CPU1_PutBuffer, "MSGRAM_CM_TO_CPU1")
#pragma DATA_SECTION(IPC_CM_To_CPU1_GetBuffer, "MSGRAM_CPU1_TO_CM")
#pragma DATA_SECTION(IPC_CM_To_CPU2_PutBuffer, "MSGRAM_CM_TO_CPU2")
#pragma DATA_SECTION(IPC_CM_To_CPU2_GetBuffer, "MSGRAM_CPU2_TO_CM")
IPC_PutBuffer_t IPC_CM_To_CPU1_PutBuffer;
IPC_GetBuffer_t IPC_CM_To_CPU1_GetBuffer;
IPC_PutBuffer_t IPC_CM_To_CPU2_PutBuffer;
IPC_GetBuffer_t IPC_CM_To_CPU2_GetBuffer;
#endif
const IPC_Instance_t IPC_Instance[IPC_TOTAL_NUM] = {
/* IPC_CM_L_CPU1_R */
{
.IPC_Flag_Ctr_Reg = (volatile IPC_Flag_Ctr_Reg_t *) IPC_CMTOCPU1_BASE,
.IPC_SendCmd_Reg = (volatile IPC_SendCmd_Reg_t *)
(IPC_CMTOCPU1_BASE + IPC_O_CMTOCPU1IPCSENDCOM),
.IPC_RecvCmd_Reg = (volatile IPC_RecvCmd_Reg_t *)
(IPC_CMTOCPU1_BASE + IPC_O_CPU1TOCMIPCRECVCOM),
.IPC_Boot_Pump_Reg = (volatile IPC_Boot_Pump_Reg_t *)
(IPC_CMTOCPU1_BASE + IPC_REG_BOOTSTS_OFFSET),
.IPC_IntNum = {INT_CPU1TOCMIPC0, INT_CPU1TOCMIPC1,
INT_CPU1TOCMIPC2, INT_CPU1TOCMIPC3,
INT_CPU1TOCMIPC4, INT_CPU1TOCMIPC5,
INT_CPU1TOCMIPC6, INT_CPU1TOCMIPC7},
.IPC_MsgRam_LtoR = CMTOCPU1MSGRAM0_BASE,
.IPC_MsgRam_RtoL = CPU1TOCMMSGRAM0_BASE,
.IPC_Offset_Corr = IPC_ADDR_OFFSET_MUL2
#if IPC_MSGQ_SUPPORT == 1U
,
.IPC_PutBuffer = &IPC_CM_To_CPU1_PutBuffer,
.IPC_GetBuffer = &IPC_CM_To_CPU1_GetBuffer
#endif
},
/* IPC_CM_L_CPU2_R */
{
.IPC_Flag_Ctr_Reg = (volatile IPC_Flag_Ctr_Reg_t *) IPC_CMTOCPU2_BASE,
.IPC_SendCmd_Reg = (volatile IPC_SendCmd_Reg_t *)
(IPC_CMTOCPU2_BASE + IPC_O_CMTOCPU2IPCSENDCOM),
.IPC_RecvCmd_Reg = (volatile IPC_RecvCmd_Reg_t *)
(IPC_CMTOCPU2_BASE + IPC_O_CPU2TOCMIPCRECVCOM),
.IPC_Boot_Pump_Reg = (volatile IPC_Boot_Pump_Reg_t *)
(IPC_CMTOCPU2_BASE + IPC_REG_BOOTSTS_OFFSET),
.IPC_IntNum = {INT_CPU2TOCMIPC0, INT_CPU2TOCMIPC1,
INT_CPU2TOCMIPC2, INT_CPU2TOCMIPC3,
INT_CPU2TOCMIPC4, INT_CPU2TOCMIPC5,
INT_CPU2TOCMIPC6, INT_CPU2TOCMIPC7},
.IPC_MsgRam_LtoR = CMTOCPU2MSGRAM0_BASE,
.IPC_MsgRam_RtoL = CPU2TOCMMSGRAM0_BASE,
.IPC_Offset_Corr = IPC_ADDR_OFFSET_MUL2
#if IPC_MSGQ_SUPPORT == 1U
,
.IPC_PutBuffer = &IPC_CM_To_CPU2_PutBuffer,
.IPC_GetBuffer = &IPC_CM_To_CPU2_GetBuffer
#endif
}
};
//*****************************************************************************
//
// IPC_sendCommand
//
//*****************************************************************************
bool IPC_sendCommand(IPC_Type_t ipcType, uint32_t flags, bool addrCorrEnable,
uint32_t command, uint32_t addr, uint32_t data)
{
bool ret;
//
// Check whether the flags are not busy
//
if((IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_FLG & flags) == 0U)
{
ret = true;
if(addrCorrEnable)
{
//
// Update the command registers. ADDR register holds the offset
// from the base address of the MSG RAM
//
IPC_Instance[ipcType].IPC_SendCmd_Reg->IPC_SENDCOM = command;
IPC_Instance[ipcType].IPC_SendCmd_Reg->IPC_SENDDATA = data;
IPC_Instance[ipcType].IPC_SendCmd_Reg->IPC_SENDADDR =
addr - IPC_Instance[ipcType].IPC_MsgRam_LtoR;
}
else
{
//
// Update the command registers. addr param remains as is.
//
IPC_Instance[ipcType].IPC_SendCmd_Reg->IPC_SENDCOM = command;
IPC_Instance[ipcType].IPC_SendCmd_Reg->IPC_SENDDATA = data;
IPC_Instance[ipcType].IPC_SendCmd_Reg->IPC_SENDADDR = addr;
}
//
// Set the flags to indicate the remote core
//
IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_SET = flags;
}
else
{
ret = false;
}
return(ret);
}
//*****************************************************************************
//
// IPC_readCommand
//
//*****************************************************************************
bool IPC_readCommand(IPC_Type_t ipcType, uint32_t flags, bool addrCorrEnable,
uint32_t *command, uint32_t *addr, uint32_t *data)
{
bool ret;
uint32_t addrReg;
//
// Check whether the flags are not empty
//
if((IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_STS & flags) != 0U)
{
ret = true;
//
// Read the command registers
//
*command = IPC_Instance[ipcType].IPC_RecvCmd_Reg->IPC_RECVCOM;
addrReg = IPC_Instance[ipcType].IPC_RecvCmd_Reg->IPC_RECVADDR;
*data = IPC_Instance[ipcType].IPC_RecvCmd_Reg->IPC_RECVDATA;
if(addrCorrEnable)
{
//
// Calculate the address form the offset
//
*addr = IPC_Instance[ipcType].IPC_MsgRam_RtoL +
IPC_ADDR_OFFSET_CORR(addrReg,
IPC_Instance[ipcType].IPC_Offset_Corr);
}
else
{
*addr = addrReg;
}
}
else
{
ret = false;
}
return(ret);
}
//*****************************************************************************
//
// IPC_registerInterrupt
//
//*****************************************************************************
void IPC_registerInterrupt(IPC_Type_t ipcType, uint32_t ipcInt,
void (*pfnHandler)(void))
{
//
// Check for arguments
//
ASSERT(ipcInt <= IPC_INT7);
//
// Get the corresponding interrupt number
//
uint32_t intNum = IPC_Instance[ipcType].IPC_IntNum[ipcInt];
//
// Register the interrupt handler
//
Interrupt_registerHandler(intNum, pfnHandler);
//
// Enable the interrupt
//
Interrupt_enable(intNum);
}
//*****************************************************************************
//
// IPC_unregisterInterrupt
//
//*****************************************************************************
void IPC_unregisterInterrupt(IPC_Type_t ipcType, uint32_t ipcInt)
{
//
// Check for arguments
//
ASSERT(ipcInt <= IPC_INT7);
//
// Get the corresponding interrupt number
//
uint32_t intNum = IPC_Instance[ipcType].IPC_IntNum[ipcInt];
//
// Disable the interrupt.
//
Interrupt_disable(intNum);
//
// Unregister the interrupt handler.
//
Interrupt_unregisterHandler(intNum);
}
#if IPC_MSGQ_SUPPORT == 1U
//*****************************************************************************
//
// IPCinitMessageQueue
//
//*****************************************************************************
void IPC_initMessageQueue(IPC_Type_t ipcType,
volatile IPC_MessageQueue_t *msgQueue,
uint32_t ipcInt_L, uint32_t ipcInt_R)
{
//
// Check for arguments
//
ASSERT(msgQueue != NULL);
ASSERT(ipcInt_L < IPC_NUM_OF_INTERRUPTS);
ASSERT(ipcInt_R < IPC_NUM_OF_INTERRUPTS);
IPC_PutBuffer_t *putBuffer = IPC_Instance[ipcType].IPC_PutBuffer;
IPC_GetBuffer_t *getBuffer = IPC_Instance[ipcType].IPC_GetBuffer;
//
// L->R Put Buffer and Index Initialization
//
msgQueue->PutBuffer = putBuffer->Buffer[ipcInt_R];
msgQueue->PutWriteIndex = &(putBuffer->PutWriteIndex[ipcInt_R]);
msgQueue->GetReadIndex = &(putBuffer->GetReadIndex[ipcInt_L]);
msgQueue->PutFlag = (uint32_t)1U << ipcInt_R;
//
// L->R Get Buffer and Index Initialization
//
msgQueue->GetBuffer = getBuffer->Buffer[ipcInt_L];
msgQueue->GetWriteIndex = &(getBuffer->GetWriteIndex[ipcInt_L]);
msgQueue->PutReadIndex = &(getBuffer->PutReadIndex[ipcInt_R]);
//
// Initialize PutBuffer WriteIndex = 0 and GetBuffer ReadIndex = 0
//
*(msgQueue->PutWriteIndex) = 0U;
*(msgQueue->GetReadIndex) = 0U;
}
//*****************************************************************************
//
// IPC_sendMessageToQueue
//
//*****************************************************************************
bool IPC_sendMessageToQueue(IPC_Type_t ipcType,
volatile IPC_MessageQueue_t *msgQueue,
bool addrCorrEnable, IPC_Message_t *msg, bool block)
{
//
// Check for arguments
//
ASSERT(msgQueue != NULL);
ASSERT(msg != NULL);
uint16_t writeIndex;
uint16_t readIndex;
bool ret = true;
writeIndex = *(msgQueue->PutWriteIndex);
readIndex = *(msgQueue->PutReadIndex);
//
// Wait until Put Buffer slot is free
//
while(((writeIndex + 1U) & IPC_MAX_BUFFER_INDEX) == readIndex)
{
//
// If designated as a "Blocking" function, and Put buffer is full,
// return immediately with fail status.
//
if(!block)
{
ret = false;
break;
}
readIndex = *(msgQueue->PutReadIndex);
}
if(ret != false)
{
//
// When slot is free, Write Message to PutBuffer, update PutWriteIndex,
// and set the CPU IPC INT Flag
//
msgQueue->PutBuffer[writeIndex] = *msg;
if(addrCorrEnable)
{
msgQueue->PutBuffer[writeIndex].address -=
IPC_Instance[ipcType].IPC_MsgRam_LtoR;
}
writeIndex = (writeIndex + 1U) & IPC_MAX_BUFFER_INDEX;
*(msgQueue->PutWriteIndex) = writeIndex;
IPC_setFlagLtoR(ipcType, msgQueue->PutFlag);
}
return(ret);
}
//*****************************************************************************
//
// IPC_readMessageFromQueue
//
//*****************************************************************************
bool IPC_readMessageFromQueue(IPC_Type_t ipcType,
volatile IPC_MessageQueue_t *msgQueue,
bool addrCorrEnable, IPC_Message_t *msg, bool block)
{
//
// Check for arguments
//
ASSERT(msgQueue != NULL);
ASSERT(msg != NULL);
uint16_t writeIndex;
uint16_t readIndex;
bool ret = true;
writeIndex = *(msgQueue->GetWriteIndex);
readIndex = *(msgQueue->GetReadIndex);
//
// Loop while GetBuffer is empty
//
while(writeIndex == readIndex)
{
//
// If designated as a "Blocking" function, and Get buffer is empty,
// return immediately with fail status.
//
if(!block)
{
ret = false;
break;
}
writeIndex = *(msgQueue->GetWriteIndex);
}
if(ret != false)
{
//
// If there is a message in GetBuffer, Read Message and update
// the ReadIndex
//
*msg = msgQueue->GetBuffer[readIndex];
if(addrCorrEnable)
{
msg->address = IPC_Instance[ipcType].IPC_MsgRam_RtoL +
IPC_ADDR_OFFSET_CORR(msg->address,
IPC_Instance[ipcType].IPC_Offset_Corr);
}
readIndex = (readIndex + 1U) & IPC_MAX_BUFFER_INDEX;
*(msgQueue->GetReadIndex) = readIndex;
}
return(ret);
}
#endif
@@ -0,0 +1,871 @@
//###########################################################################
//
// FILE: ipc.h
//
// TITLE: CM IPC driver.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef IPC_H
#define IPC_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup ipc_api IPC
//! \brief This module is used for inter-processor communications.
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "debug.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ipc.h"
#include "inc/hw_ints.h"
#include "interrupt.h"
//*****************************************************************************
//
// Defines for the APIs
//
//*****************************************************************************
//*****************************************************************************
//
// Driver configuration macros
//
//*****************************************************************************
#define IPC_MSGQ_SUPPORT 1U
//
// Number of IPC messages in circular buffer (must be interval of 2)
//
#define IPC_BUFFER_SIZE 4U
//
// Number of IPC interrupts using circular buffer (must be same number on both
// CPUs)
//
#define IPC_NUM_OF_INTERRUPTS 4U
//*****************************************************************************
//
// Values that can be passed as parameter flags in all the IPC API functions.
//
//*****************************************************************************
#ifndef IPC_FLAGS_DEFINED
#define IPC_FLAGS_DEFINED
#define IPC_NO_FLAG 0x00000000U //!< NO FLAG
#define IPC_FLAG0 0x00000001U //!< IPC FLAG 0
#define IPC_FLAG1 0x00000002U //!< IPC FLAG 1
#define IPC_FLAG2 0x00000004U //!< IPC FLAG 2
#define IPC_FLAG3 0x00000008U //!< IPC FLAG 3
#define IPC_FLAG4 0x00000010U //!< IPC FLAG 4
#define IPC_FLAG5 0x00000020U //!< IPC FLAG 5
#define IPC_FLAG6 0x00000040U //!< IPC FLAG 6
#define IPC_FLAG7 0x00000080U //!< IPC FLAG 7
#define IPC_FLAG8 0x00000100U //!< IPC FLAG 8
#define IPC_FLAG9 0x00000200U //!< IPC FLAG 9
#define IPC_FLAG10 0x00000400U //!< IPC FLAG 10
#define IPC_FLAG11 0x00000800U //!< IPC FLAG 11
#define IPC_FLAG12 0x00001000U //!< IPC FLAG 12
#define IPC_FLAG13 0x00002000U //!< IPC FLAG 13
#define IPC_FLAG14 0x00004000U //!< IPC FLAG 14
#define IPC_FLAG15 0x00008000U //!< IPC FLAG 15
#define IPC_FLAG16 0x00010000U //!< IPC FLAG 16
#define IPC_FLAG17 0x00020000U //!< IPC FLAG 17
#define IPC_FLAG18 0x00040000U //!< IPC FLAG 18
#define IPC_FLAG19 0x00080000U //!< IPC FLAG 19
#define IPC_FLAG20 0x00100000U //!< IPC FLAG 20
#define IPC_FLAG21 0x00200000U //!< IPC FLAG 21
#define IPC_FLAG22 0x00400000U //!< IPC FLAG 22
#define IPC_FLAG23 0x00800000U //!< IPC FLAG 23
#define IPC_FLAG24 0x01000000U //!< IPC FLAG 24
#define IPC_FLAG25 0x02000000U //!< IPC FLAG 25
#define IPC_FLAG26 0x04000000U //!< IPC FLAG 26
#define IPC_FLAG27 0x08000000U //!< IPC FLAG 27
#define IPC_FLAG28 0x10000000U //!< IPC FLAG 28
#define IPC_FLAG29 0x20000000U //!< IPC FLAG 29
#define IPC_FLAG30 0x40000000U //!< IPC FLAG 30
#define IPC_FLAG31 0x80000000U //!< IPC FLAG 31
#define IPC_FLAG_ALL 0xFFFFFFFFU //!< All IPC flags
#endif
//*****************************************************************************
//
// Values that can be passed as parameter ipcInt in
// IPC_registerInterrupt and IPC_unregisterInterrupt functions.
// Please refer to the datasheet for the actual number of interrupts available
// for each IPC instance
//
//*****************************************************************************
#define IPC_INT0 0x0U //!< IPC Interrupt 0
#define IPC_INT1 0x1U //!< IPC Interrupt 1
#define IPC_INT2 0x2U //!< IPC Interrupt 2
#define IPC_INT3 0x3U //!< IPC Interrupt 3
#define IPC_INT4 0x4U //!< IPC Interrupt 4
#define IPC_INT5 0x5U //!< IPC Interrupt 5
#define IPC_INT6 0x6U //!< IPC Interrupt 6
#define IPC_INT7 0x7U //!< IPC Interrupt 7
//*****************************************************************************
//
// Values that can be passed as parameter addrCorrEnable in
// IPC_sendCommand, IPC_readCommand, IPC_sendMessageToQueue and
// IPC_readMessageFromQueue functions.
//
//*****************************************************************************
#define IPC_ADDR_CORRECTION_ENABLE true
#define IPC_ADDR_CORRECTION_DISABLE false
//*****************************************************************************
//
// Values that can be passed as parameter block in
// IPC_sendMessageToQueue and IPC_readMessageFromQueue functions.
//
//*****************************************************************************
#define IPC_BLOCKING_CALL true
#define IPC_NONBLOCKING_CALL false
//*****************************************************************************
//
// Macros used to get and release the flash pump semaphore
//
//*****************************************************************************
#define IPC_PUMPREQUEST_REG \
IPC_Instance[IPC_CM_L_CPU1_R].IPC_Boot_Pump_Reg->IPC_PUMPREQUEST
//*****************************************************************************
//
// Internal macros used for message queue implementation
//
//*****************************************************************************
#define IPC_MAX_BUFFER_INDEX (IPC_BUFFER_SIZE - 1U)
//*****************************************************************************
//
// Enums for the APIs
//
//*****************************************************************************
//*****************************************************************************
//
//! Values that can be passed as parameter \e ipcType in all the driver
//! functions
//
//*****************************************************************************
typedef enum
{
IPC_CM_L_CPU1_R, //!< CM - Local core, CPU1 - Remote core
IPC_CM_L_CPU2_R, //!< CM - Local core, CPU2 - Remote core
IPC_TOTAL_NUM
}IPC_Type_t;
//*****************************************************************************
//
// Internal structs for register and messaage queue accesses
//
//*****************************************************************************
typedef struct
{
uint32_t IPC_ACK;
uint32_t IPC_STS;
uint32_t IPC_SET;
uint32_t IPC_CLR;
uint32_t IPC_FLG;
uint32_t IPC_RSVDREG;
uint32_t IPC_COUNTERL;
uint32_t IPC_COUNTERH;
}IPC_Flag_Ctr_Reg_t;
typedef struct
{
uint32_t IPC_SENDCOM;
uint32_t IPC_SENDADDR;
uint32_t IPC_SENDDATA;
uint32_t IPC_REMOTEREPLY;
}IPC_SendCmd_Reg_t;
typedef struct
{
uint32_t IPC_RECVCOM;
uint32_t IPC_RECVADDR;
uint32_t IPC_RECVDATA;
uint32_t IPC_LOCALREPLY;
}IPC_RecvCmd_Reg_t;
typedef struct
{
uint32_t IPC_BOOTSTS;
uint32_t IPC_BOOTMODE;
uint32_t IPC_PUMPREQUEST;
}IPC_Boot_Pump_Reg_t;
#if IPC_MSGQ_SUPPORT == 1U
typedef struct
{
uint32_t command;
uint32_t address;
uint32_t dataw1;
uint32_t dataw2;
}IPC_Message_t;
typedef struct
{
IPC_Message_t Buffer[IPC_NUM_OF_INTERRUPTS][IPC_BUFFER_SIZE];
uint16_t PutWriteIndex[IPC_NUM_OF_INTERRUPTS];
uint16_t GetReadIndex[IPC_NUM_OF_INTERRUPTS];
}IPC_PutBuffer_t;
typedef struct
{
IPC_Message_t Buffer[IPC_NUM_OF_INTERRUPTS][IPC_BUFFER_SIZE];
uint16_t GetWriteIndex[IPC_NUM_OF_INTERRUPTS];
uint16_t PutReadIndex[IPC_NUM_OF_INTERRUPTS];
}IPC_GetBuffer_t;
#endif
//*****************************************************************************
//
// Internal struct used to store the required information regarding an IPC
// instance
//
//*****************************************************************************
typedef struct
{
volatile IPC_Flag_Ctr_Reg_t *IPC_Flag_Ctr_Reg;
volatile IPC_SendCmd_Reg_t *IPC_SendCmd_Reg;
volatile IPC_RecvCmd_Reg_t *IPC_RecvCmd_Reg;
volatile IPC_Boot_Pump_Reg_t *IPC_Boot_Pump_Reg;
uint32_t IPC_IntNum[8U];
uint32_t IPC_MsgRam_LtoR;
uint32_t IPC_MsgRam_RtoL;
uint32_t IPC_Offset_Corr;
#if IPC_MSGQ_SUPPORT == 1U
IPC_PutBuffer_t *IPC_PutBuffer;
IPC_GetBuffer_t *IPC_GetBuffer;
#endif
}IPC_Instance_t;
extern const IPC_Instance_t IPC_Instance[IPC_TOTAL_NUM];
#if IPC_MSGQ_SUPPORT == 1U
//*****************************************************************************
//
// A structure that defines an IPC message queue. These
// fields are used by the IPC drivers, and normally it is not necessary for
// user software to directly read or write fields in the table.
//
//*****************************************************************************
typedef struct
{
IPC_Message_t * PutBuffer;
uint32_t PutFlag;
uint16_t * PutWriteIndex;
uint16_t * PutReadIndex;
IPC_Message_t * GetBuffer;
uint16_t * GetWriteIndex;
uint16_t * GetReadIndex;
} IPC_MessageQueue_t;
#endif
//*****************************************************************************
//
// API Function prototypes
//
//*****************************************************************************
//*****************************************************************************
//
//! Local core sets Local to Remote IPC Flag
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flags is the IPC flag mask for the flags being set
//!
//! This function will allow the Local core system to set the designated IPC
//! flags to send to the Remote core system. The \e flags parameter can be any
//! of the IPC flag values: \b IPC_FLAG0 - \b IPC_FLAG31.
//!
//! \return None.
//
//*****************************************************************************
static inline void
IPC_setFlagLtoR(IPC_Type_t ipcType, uint32_t flags)
{
IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_SET = flags;
}
//*****************************************************************************
//
//! Local core clears Local to Remote IPC Flag
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flags is the IPC flag mask for the flags being cleared
//!
//! This function will allow the Local core system to clear the designated IPC
//! flags sent to the Remote core system. The \e flags parameter can be any
//! of the IPC flag values: \b IPC_FLAG0 - \b IPC_FLAG31.
//!
//! \return None.
//
//*****************************************************************************
static inline void
IPC_clearFlagLtoR(IPC_Type_t ipcType, uint32_t flags)
{
IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_CLR = flags;
}
//*****************************************************************************
//
//! Local core acknowledges Remote to Local IPC Flag.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flags is the IPC flag mask for the flags being acknowledged.
//!
//! This function will allow the Local core system to acknowledge/clear the IPC
//! flag set by the Remote core system. The \e flags parameter can be any of
//! the IPC flag values: \b IPC_FLAG0 - \b IPC_FLAG31.
//!
//! \return None.
//
//*****************************************************************************
static inline void
IPC_ackFlagRtoL(IPC_Type_t ipcType, uint32_t flags)
{
IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_ACK = flags;
}
//*****************************************************************************
//
//! Determines whether the given IPC flags are busy or not.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flags is the Local to Remote IPC flag masks to check the status of
//!
//! Allows the caller to determine whether the designated Local to Remote
//! IPC flags are pending. The \e flags parameter can be any of the IPC flag
//! values: \b IPC_FLAG0 - \b IPC_FLAG31.
//!
//! \return Returns \b true if the any of the designated IPC flags are busy
//! or \b false if all the designated IPC flags are free.
//
//*****************************************************************************
static inline bool
IPC_isFlagBusyLtoR(IPC_Type_t ipcType, uint32_t flags)
{
return((IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_FLG & flags) != 0U);
}
//*****************************************************************************
//
//! Determines whether the given Remote to Local IPC flags are busy or not.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flags is the Remote to Local IPC Flag masks to check the status of
//!
//! Allows the caller to determine whether the designated Remote to Local
//! IPC flags are pending. The \e flags parameter can be any of the IPC flag
//! values: \b IPC_FLAG0 - \b IPC_FLAG31.
//!
//! \return Returns \b true if the any of the designated IPC flags are busy
//! or \b false if all the designated IPC flags are free.
//
//*****************************************************************************
static inline bool
IPC_isFlagBusyRtoL(IPC_Type_t ipcType, uint32_t flags)
{
return((IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_STS & flags) != 0U);
}
//*****************************************************************************
//
//! Wait for the remote core to send a flag
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flag is the Remote to Local IPC flag mask to wait for
//!
//! Allows the caller to wait for the Remote to Local flag to be send by
//! the remote core. The \e flags parameter can be any of the IPC flag
//! values: \b IPC_FLAG0 - \b IPC_FLAG31.
//!
//! \return None
//
//*****************************************************************************
static inline void
IPC_waitForFlag(IPC_Type_t ipcType, uint32_t flag)
{
while((IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_STS & flag) == 0U)
{
}
}
//*****************************************************************************
//
//! Wait for the IPC flag to be acknowledged
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flag is the IPC flag mask for which ack is pending
//!
//! Allows the caller to wait for the IPC flag to be acknowledged by the
//! remote core. The \e flagsparameter can be any of the IPC flag values:
//! \b IPC_FLAG0 - \b IPC_FLAG31.
//!
//! \return None
//
//*****************************************************************************
static inline void
IPC_waitForAck(IPC_Type_t ipcType, uint32_t flag)
{
while((IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_FLG & flag) != 0U)
{
}
}
//*****************************************************************************
//
//! Synchronises the two cores
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flag is the IPC flag mask with which synchronisation is done
//!
//! Allows the local and remote cores to synchronise. Neither core will return
//! from this function call before the other core enters it.
//!
//! \note Must be called with same flag mask on both the cores
//!
//! \return None
//
//*****************************************************************************
static inline void
IPC_sync(IPC_Type_t ipcType, uint32_t flag)
{
IPC_setFlagLtoR(ipcType, flag);
IPC_waitForFlag(ipcType, flag);
IPC_ackFlagRtoL(ipcType, flag);
IPC_waitForAck(ipcType, flag);
}
//*****************************************************************************
//
//! Initialize IPC
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//
//! This function initializes IPC by clearing all the flags
//!
//! \return None
//
//*****************************************************************************
static inline void
IPC_init(IPC_Type_t ipcType)
{
IPC_clearFlagLtoR(ipcType, IPC_FLAG_ALL);
}
//*****************************************************************************
//
//! Sends a command to the Remote core
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flags is the IPC flag mask for the flags to be set
//! \param addrCorrEnable is the flag used to determine whether or not to
//! convert the addr parameter to remote core's address space
//! \param command is the 32-bit command value
//! \param addr is the 32-bit address to be sent as part of command
//! \param data is the 32-bit data to be sent as part of command
//!
//! Allows the caller to send a command to the remote core. A command consists
//! of a unique command value, a 32-bit address and a 32-bit data. The function
//! also sends the designated flags to the remote core.
//! There may be differences in the address spaces of Local and Remote core.
//! For example in case of F2838X device, the address spaces of C28x core and
//! CM core are different. In case the \e addr refers to an address in the IPC
//! MSG RAM, \e addrCorrEnable param may be used to correct the address mismatch
//!
//! The \e flags parameter can be any of the IPC flag values: \b IPC_FLAG0 -
//! \b IPC_FLAG31.
//! The \e addrCorrEnable parameter can take values IPC_ADDR_CORRECTION_ENABLE
//! (converts the address to remote core's address space) or
//! IPC_ADDR_CORRECTION_DISABLE(does not modify the addr parmeter)
//!
//! The application shall use the function IPC_getResponse to read the response
//! sent by the remote core.
//!
//! \note The application is expected to wait until the the response is
//! received before sending another command.
//!
//! \note \e addrCorrEnable parameter must be kept same on the sending and
//! receiving cores
//!
//! \return Returns \b true if the command is sent properly and \b false if
//! the designated flags were busy and hence command was not sent.
//
//*****************************************************************************
extern bool
IPC_sendCommand(IPC_Type_t ipcType, uint32_t flags, bool addrCorrEnable,
uint32_t command, uint32_t addr, uint32_t data);
//*****************************************************************************
//
//! Reads a command sent by the Remote core
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param flags is the IPC flag mask for the flags sent by the remote core
//! \param addrCorrEnable is the flag used to determine whether or not to
//! convert the addr parameter to remote core's address space
//! \param command is the 32-bit pointer at which the command value is read to
//! \param addr is the 32-bit pointer at which address value is read to
//! \param data is the 32-bit pointer at which the data is read to
//!
//! Allows the caller to read a command sent by the remote core. A command
//! consists of a unique command value, a 32-bit address and a 32-bit data.
//! There may be differences in the address spaces of Local and Remote core.
//! For example in case of F2838X device, the address spaces of C28x core and
//! CM core are different. In case the \e addr refers to an address in the IPC
//! MSG RAM, \e addrCorrEnable param may be used to correct the address mismatch
//!
//! The \e flags parameter can be any of the IPC flag values: \b IPC_FLAG0 -
//! \b IPC_FLAG31.
//! The \e addrCorrEnable parameter can take values IPC_ADDR_CORRECTION_ENABLE
//! (converts the address to remote core's address space) or
//! IPC_ADDR_CORRECTION_DISABLE(does not modify the addr parmeter)
//!
//! \note The application is expected to acknowledge the flag and send a
//! response (if needed) after reading the command
//!
//! \note \e addrCorrEnable parameter must be kept same on the sending and
//! receiving cores
//!
//! \return Returns \b true if the command is read properly and \b false if
//! the designated flags were empty and hence command was not read.
//
//*****************************************************************************
extern bool
IPC_readCommand(IPC_Type_t ipcType, uint32_t flags, bool addrCorrEnable,
uint32_t *command, uint32_t *addr, uint32_t *data);
//*****************************************************************************
//
//! Sends the response to the command sent by remote core.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param data is the 32-bit value of the response to be sent
//!
//! Allows the caller to send a response to the command previously sent by the
//! remote core
//!
//! \return None.
//
//*****************************************************************************
static inline void
IPC_sendResponse(IPC_Type_t ipcType, uint32_t data)
{
IPC_Instance[ipcType].IPC_RecvCmd_Reg->IPC_LOCALREPLY = data;
}
//*****************************************************************************
//
//! Reads the response from the remote core.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//!
//! Allows the caller to read the response sent by the remote core to the
//! command previously sent by the local core
//!
//! \return the 32-bit value of the response.
//
//*****************************************************************************
static inline uint32_t
IPC_getResponse(IPC_Type_t ipcType)
{
return(IPC_Instance[ipcType].IPC_SendCmd_Reg->IPC_REMOTEREPLY);
}
//*****************************************************************************
//
//! Reads the BOOTMODE register.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//!
//! Allows the caller to read the BOOTMODE register.
//!
//! \note Boot registers are not available in CPU2<->CM IPC instance
//!
//! \return 32-bit value of the BOOOTMODE register
//
//*****************************************************************************
static inline uint32_t
IPC_getBootMode(IPC_Type_t ipcType)
{
return(IPC_Instance[ipcType].IPC_Boot_Pump_Reg->IPC_BOOTMODE);
}
//*****************************************************************************
//
//! Sets the BOOTSTS register.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param status is the 32-bit value to be set
//!
//! Allows the caller to set the BOOTSTS register.
//!
//! \note This function shall be called by CPU2 and CM only
//!
//! \note This function shall be called by CPU2 and CM only. Boot registers
//! are not available in CPU2<->CM IPC instance
//!
//! \return None.
//
//*****************************************************************************
static inline void
IPC_setBootStatus(IPC_Type_t ipcType, uint32_t status)
{
ASSERT(ipcType == IPC_CM_L_CPU1_R);
IPC_Instance[ipcType].IPC_Boot_Pump_Reg->IPC_BOOTSTS = status;
}
//*****************************************************************************
//
//! Reads the BOOTSTS register.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//!
//! Allows the caller to set the BOOTMODE register.
//!
//! \note Boot registers are not available in CPU2<->CM IPC instance
//!
//! \return 32-bit value of the BOOOTSTS register
//
//*****************************************************************************
static inline uint32_t
IPC_getBootStatus(IPC_Type_t ipcType)
{
return(IPC_Instance[ipcType].IPC_Boot_Pump_Reg->IPC_BOOTSTS);
}
//*****************************************************************************
//
//! Reads the timestamp counter value.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//!
//! Allows the caller to read the IPC timestamp counter value.
//!
//! \return 64-bit counter value.
//
//*****************************************************************************
static inline uint64_t
IPC_getCounter(IPC_Type_t ipcType)
{
//
// Get the Counter High and Low values. Read to the Counter low register
// saves the value of Counter High register.
//
uint32_t ctrL = IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_COUNTERL;
uint32_t ctrH = IPC_Instance[ipcType].IPC_Flag_Ctr_Reg->IPC_COUNTERH;
//
// Return the 64-bit value of the counter
//
return(((uint64_t)ctrH << 32) | ((uint64_t)ctrL));
}
//*****************************************************************************
//
//! Registers an interrupt handler for IPC
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param ipcInt is the Flag number for which interrupt is being registered
//! \param pfnHandler is the pointer to ISR function
//!
//! This function registers the handler to be called when an IPC interrupt
//! occurs. This function enables the global interrupt in the interrupt
//! controller.
//! The \e ipcInt parameter can be any of the IPC flag values:\b IPC_INT0 -
//! \b IPC_INT7. IPC_INT0 corresponds to IPC Flag 0 interrupt and so on.
//
//*****************************************************************************
extern void
IPC_registerInterrupt(IPC_Type_t ipcType, uint32_t ipcInt,
void (*pfnHandler)(void));
//*****************************************************************************
//
//! Unregisters an interrupt handler for IPC
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param ipcInt is the Flag number for which interrupt is being unregistered
//!
//! This function clears the handler to be called when an IPC interrupt
//! occurs. This function also masks off the interrupt in the interrupt
//! controller so that the interrupt handler no longer is called.
//! The \e ipcInt parameter can be any of the IPC flag values:\b IPC_INT0 -
//! \b IPC_INT7. IPC_INT0 corresponds to IPC Flag 0 interrupt and so on.
//
//*****************************************************************************
extern void
IPC_unregisterInterrupt(IPC_Type_t ipcType, uint32_t ipcInt);
#if IPC_MSGQ_SUPPORT == 1U
//*****************************************************************************
//
//! Initializes the IPC message queue
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param msgQueue specifies the address of a \e IPC_MessageQueue_t instance
//! \param ipcInt_L specifies the interrupt number on the local core used by
//! the message queue .
//! \param ipcInt_R specifies the interrupt number on the remote core used by
//! the message queue.
//!
//! This function initializes the IPC message queue with circular buffer
//! and index addresses for an IPC interrupt pair. The
//! \e ipcInt_L and \e ipcInt_R parameters can be one of the following values:
//! \b IPC_INT0, \b IPC_INT1, \b IPC_INT2, \b IPC_INT3.
//!
//! \note If an interrupt is currently in use by an \e IPC_MessageQueue_t
//! instance, that particular interrupt should not be tied to a second
//! \e IPC_MessageQueue_t instance.
//!
//! \note For a particular ipcInt_L - ipcInt_R pair, there must be an instance
//! of IPC_MessageQueue_t defined and initialized on both the locakl and remote
//! systems.
//!
//! \return None.
//
//*****************************************************************************
extern void
IPC_initMessageQueue(IPC_Type_t ipcType, volatile IPC_MessageQueue_t *msgQueue,
uint32_t ipcInt_L, uint32_t ipcInt_R);
//*****************************************************************************
//
//! Sends a message into the messageQueue.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param msgQueue specifies the address of a \e IPC_MessageQueue_t instance
//! \param addrCorrEnable is the flag used to determine whether or not to
//! convert the addr parameter to remote core's address space
//! \param msg specifies the address of the \e IPC_Message_t instance to be
//! sent to message queue.
//! \param block specifies whether to allow function to block until the buffer
//! has a free slot
//!
//! This function checks if there is a free slot in the message queue. If so, it
//! puts the message pointed to by \e msg into the free and sets the
//! appropriate IPC interrupt flag
//!
//! The \e addrCorrEnable parameter can take values IPC_ADDR_CORRECTION_ENABLE
//! (converts the address to remote core's address space) or
//! IPC_ADDR_CORRECTION_DISABLE(does not modify the addr parmeter)
//! The \e block parameter can be one of the following values:
//! \b IPC_BLOCKING_CALL or \b IPC_NONBLOCKING_CALL.
//!
//! \return \b false if the queue is full. \b true if the message is
//! successfully sent.
//
//*****************************************************************************
extern bool
IPC_sendMessageToQueue(IPC_Type_t ipcType,
volatile IPC_MessageQueue_t *msgQueue,
bool addrCorrEnable, IPC_Message_t *msg, bool block);
//*****************************************************************************
//
//! Reads a message from the messageQueue.
//!
//! \param ipcType is the enum corresponding to the IPC instance used
//! \param msgQueue specifies the address of a \e IPC_MessageQueue_t instance
//! \param addrCorrEnable is the flag used to determine whether or not to
//! convert the addr parameter to remote core's address space
//! \param msg specifies the address of the \e IPC_Message_t instance to which
//! the message needs to be read
//! \param block specifies whether to allow function to block until a message
//! is available in the message queue
//!
//! This function checks if there is a message in the message queue. If so, it
//! reads the message and writes to the address pointed to by \e msg into.
//!
//! The \e addrCorrEnable parameter can take values IPC_ADDR_CORRECTION_ENABLE
//! (converts the address to remote core's address space) or
//! IPC_ADDR_CORRECTION_DISABLE(does not modify the addr parmeter)
//! The \e block parameter can be one of the following values:
//! \b IPC_BLOCKING_CALL or \b IPC_NONBLOCKING_CALL.
//!
//! \return \b false if the queue is empty. \b true if the message successfully
//! read.
//
//*****************************************************************************
extern bool
IPC_readMessageFromQueue(IPC_Type_t ipcType,
volatile IPC_MessageQueue_t *msgQueue,
bool addrCorrEnable, IPC_Message_t *msg, bool block);
#endif
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // IPC_H
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,655 @@
//###########################################################################
//
// FILE: memcfg.c
//
// TITLE: CM SRAM config driver.
//
//###########################################################################
//
// 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 "memcfg.h"
//*****************************************************************************
//
// MemCfg_lockConfig
//
//*****************************************************************************
void
MemCfg_lockConfig(uint32_t memSections)
{
//
// Check the arguments.
//
ASSERT(((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CX) ||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_SX) ||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_ROM) ||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_PERIMEM)||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CMMSGX) ||
(memSections == MEMCFG_SECT_ALL));
//
// Set the bit that blocks writes to the sections' configuration registers.
//
switch(memSections & MEMCFG_SECT_TYPE_MASK)
{
case MEMCFG_SECT_TYPE_CX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CXLOCK) |= (MEMCFG_SECT_NUM_MASK &
memSections);
break;
case MEMCFG_SECT_TYPE_CMMSGX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXLOCK) |= (MEMCFG_SECT_NUM_MASK
& memSections);
break;
case MEMCFG_SECT_TYPE_SX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_LOCK) |=
(MEMCFG_SECT_NUM_MASK & memSections);
break;
case MEMCFG_SECT_TYPE_ROM:
HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_LOCK) |= (MEMCFG_SECT_NUM_MASK &
memSections);
break;
case MEMCFG_SECT_TYPE_PERIMEM:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_LOCK) |=
(MEMCFG_SECT_NUM_MASK & memSections);
break;
case MEMCFG_SECT_TYPE_MASK:
//
// Lock configuration for all sections.
//
HWREG(CMMEMCFG_BASE + MEMCFG_O_CXLOCK) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_CX_ALL);
HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXLOCK) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_CMMSGX_ALL);
HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_LOCK) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_SX_ALL);
HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_LOCK) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_ROM);
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_LOCK) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_PERIMEM_ALL);
break;
default:
//
// Do nothing. Invalid memSections. Make sure you aren't OR-ing
// values for two different types of RAM.
//
break;
}
}
//*****************************************************************************
//
// MemCfg_unlockConfig
//
//*****************************************************************************
void
MemCfg_unlockConfig(uint32_t memSections)
{
//
// Check the arguments.
//
ASSERT(((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CX) ||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_SX) ||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_ROM) ||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_PERIMEM)||
((memSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CMMSGX) ||
(memSections == MEMCFG_SECT_ALL));
//
// Clear the bit that blocks writes to the sections' configuration
// registers.
//
switch(memSections & MEMCFG_SECT_TYPE_MASK)
{
case MEMCFG_SECT_TYPE_CX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CXLOCK) &=
~(MEMCFG_SECT_NUM_MASK & memSections);
break;
case MEMCFG_SECT_TYPE_CMMSGX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXLOCK) &=
~(MEMCFG_SECT_NUM_MASK & memSections);
break;
case MEMCFG_SECT_TYPE_SX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_LOCK) &=
~(MEMCFG_SECT_NUM_MASK & memSections);
break;
case MEMCFG_SECT_TYPE_ROM:
HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_LOCK) &=
~(MEMCFG_SECT_NUM_MASK & memSections);
break;
case MEMCFG_SECT_TYPE_PERIMEM:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_LOCK) &=
~(MEMCFG_SECT_NUM_MASK & memSections);
break;
case MEMCFG_SECT_TYPE_MASK:
//
// Lock configuration for all sections.
//
HWREG(CMMEMCFG_BASE + MEMCFG_O_CXLOCK) &= ~((uint32_t)
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_CX_ALL));
HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXLOCK) &= ~((uint32_t)
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_CMMSGX_ALL));
HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_LOCK) &= ~((uint32_t)
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_SX_ALL));
HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_LOCK) &= ~((uint32_t)
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_ROM));
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_LOCK) &= ~((uint32_t)
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_PERIMEM_ALL));
break;
default:
//
// Do nothing. Invalid memSections. Make sure you aren't OR-ing
// values for two different types of RAM.
//
break;
}
}
//*****************************************************************************
//
// MemCfg_setTestMode
//
//*****************************************************************************
void
MemCfg_setTestMode(uint32_t memSection, MemCfg_TestMode testMode)
{
uint32_t shiftVal = 0U;
uint32_t maskVal;
uint32_t regVal;
uint32_t sectionNum;
//
// Check the arguments.
//
ASSERT(((memSection & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CX) ||
((memSection & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_SX) ||
((memSection & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_ROM) ||
((memSection & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CMMSGX));
//
// Calculate how far the protect mode value needs to be shifted. Each
// section number is represented by a bit in the lower word of memSection
// and 2 bits in the corresponding TEST register.
//
sectionNum = memSection & MEMCFG_SECT_NUM_MASK;
while(sectionNum != 1U)
{
sectionNum = sectionNum >> 1U;
shiftVal += 2U;
}
maskVal = (uint32_t)MEMCFG_TESTMODE_M << shiftVal;
regVal = ((uint32_t)testMode) << shiftVal;
//
// Write the test mode into the appropriate field
//
switch(memSection & MEMCFG_SECT_TYPE_MASK)
{
case MEMCFG_SECT_TYPE_CX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CXTEST) =
((HWREG(CMMEMCFG_BASE + MEMCFG_O_CXTEST) & ~maskVal) | regVal);
break;
case MEMCFG_SECT_TYPE_CMMSGX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXTEST) =
((HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXTEST) & ~maskVal) | regVal);
break;
case MEMCFG_SECT_TYPE_SX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_TEST) =
((HWREG(CMMEMCFG_BASE + MEMCFG_O_CXTEST) & ~maskVal) | regVal);
break;
case MEMCFG_SECT_TYPE_ROM:
HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_TEST) =
((HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_TEST) & ~maskVal) | regVal);
break;
default:
//
// Do nothing. Invalid memSection.
//
break;
}
}
//*****************************************************************************
//
// MemCfg_initSections
//
//*****************************************************************************
void
MemCfg_initSections(uint32_t ramSections)
{
//
// Check the arguments.
//
ASSERT(((ramSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CX) ||
((ramSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_SX) ||
((ramSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CMMSGX) ||
(ramSections == MEMCFG_SECT_ALL));
//
// Set the bit in the various initialization registers that starts
// initialization.
//
switch(ramSections & MEMCFG_SECT_TYPE_MASK)
{
case MEMCFG_SECT_TYPE_CX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CXINIT) |=
(MEMCFG_SECT_NUM_MASK & ramSections);
break;
case MEMCFG_SECT_TYPE_CMMSGX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXINIT) |=
(MEMCFG_SECT_NUM_MASK & ramSections);
break;
case MEMCFG_SECT_TYPE_SX:
HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_INIT) |=
(MEMCFG_SECT_NUM_MASK & ramSections);
break;
case MEMCFG_SECT_TYPE_MASK:
//
// Initialize all sections.
//
HWREG(CMMEMCFG_BASE + MEMCFG_O_CXINIT) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_CX_ALL);
HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXINIT) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_CMMSGX_ALL);
HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_INIT) |=
(MEMCFG_SECT_NUM_MASK & MEMCFG_SECT_SX_ALL);
break;
default:
//
// Do nothing. Invalid ramSections. Make sure you aren't OR-ing
// values for two different types of RAM.
//
break;
}
}
//*****************************************************************************
//
// MemCfg_getInitStatus
//
//*****************************************************************************
bool
MemCfg_getInitStatus(uint32_t ramSections)
{
uint32_t status;
//
// Check the arguments.
//
ASSERT(((ramSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CX) ||
((ramSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_SX) ||
((ramSections & MEMCFG_SECT_TYPE_MASK) == MEMCFG_SECT_TYPE_CMMSGX) ||
(ramSections == MEMCFG_SECT_ALL));
//
// Read registers containing the initialization complete status.
//
switch(ramSections & MEMCFG_SECT_TYPE_MASK)
{
case MEMCFG_SECT_TYPE_CX:
status = HWREG(CMMEMCFG_BASE + MEMCFG_O_CXINITDONE);
break;
case MEMCFG_SECT_TYPE_CMMSGX:
status = HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXINITDONE);
break;
case MEMCFG_SECT_TYPE_SX:
status = HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_INITDONE);
break;
case MEMCFG_SECT_TYPE_MASK:
//
// Return the overall status.
//
if((HWREG(CMMEMCFG_BASE + MEMCFG_O_CXINITDONE) ==
MEMCFG_SECT_CX_ALL) &&
(HWREG(CMMEMCFG_BASE + MEMCFG_O_CMMSGXINITDONE) ==
MEMCFG_SECT_CMMSGX_ALL) &&
(HWREG(CMMEMCFG_BASE + MEMCFG_O_SXGROUP1_INITDONE) ==
MEMCFG_SECT_SX_ALL))
{
status = MEMCFG_SECT_NUM_MASK;
}
else
{
status = 0x0U;
}
break;
default:
//
// Invalid ramSections. Make sure you aren't OR-ing values for two
// different types of RAM.
//
status = 0x0U;
break;
}
return((ramSections & status) == (ramSections & MEMCFG_SECT_NUM_MASK));
}
//*****************************************************************************
//
// MemCfg_forceMemError
//
//*****************************************************************************
void
MemCfg_forceMemError(uint32_t memTypes)
{
//
// Check the arguments.
//
ASSERT((memTypes == MEMCFG_SECT_ROM) ||
(memTypes == MEMCFG_SECT_PERIMEM_EMAC) ||
(memTypes == MEMCFG_SECT_PERIMEM_ETHERCAT) ||
(memTypes == MEMCFG_SECT_ALL));
//
// Forces error in the selected memory.
//
switch(memTypes)
{
case MEMCFG_SECT_ROM:
HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_FORCE_ERROR) |=
MEMCFG_ROM_FORCE_ERROR_FORCE_BOOTROM_ERROR;
break;
case MEMCFG_SECT_PERIMEM_EMAC:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_MEM_FORCE_ERROR;
break;
case MEMCFG_SECT_PERIMEM_ETHERCAT:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_MEM_FORCE_ERROR;
break;
case MEMCFG_SECT_ALL:
HWREG(CMMEMCFG_BASE + MEMCFG_O_ROM_FORCE_ERROR) |=
MEMCFG_ROM_FORCE_ERROR_FORCE_BOOTROM_ERROR;
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_MEM_FORCE_ERROR;
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_MEM_FORCE_ERROR;
break;
default:
//
// Do nothing. Invalid memory.
//
break;
}
}
//*****************************************************************************
//
// MemCfg_enablePeriMemTestMode
//
//*****************************************************************************
void
MemCfg_enablePeriMemTestMode(uint32_t memTypes)
{
//
// Check the arguments.
//
ASSERT((memTypes == MEMCFG_SECT_PERIMEM_EMAC) ||
(memTypes == MEMCFG_SECT_PERIMEM_ETHERCAT) ||
(memTypes == MEMCFG_SECT_PERIMEM_ALL));
//
// Enables test mode for selected memory type.
//
switch(memTypes)
{
case MEMCFG_SECT_PERIMEM_EMAC:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_TEST_ENABLE;
break;
case MEMCFG_SECT_PERIMEM_ETHERCAT:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_TEST_ENABLE;
break;
case MEMCFG_SECT_PERIMEM_ALL:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_TEST_ENABLE;
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) |=
MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_TEST_ENABLE;
break;
default:
//
// Do nothing. Invalid memory type.
//
break;
}
}
//*****************************************************************************
//
// MemCfg_disablePeriMemTestMode
//
//*****************************************************************************
void
MemCfg_disablePeriMemTestMode(uint32_t memTypes)
{
//
// Check the arguments.
//
ASSERT((memTypes == MEMCFG_SECT_PERIMEM_EMAC) ||
(memTypes == MEMCFG_SECT_PERIMEM_ETHERCAT) ||
(memTypes == MEMCFG_SECT_PERIMEM_ALL));
//
// Disables test mode for selected memory type.
//
switch(memTypes)
{
case MEMCFG_SECT_PERIMEM_EMAC:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) &=
~MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_TEST_ENABLE;
break;
case MEMCFG_SECT_PERIMEM_ETHERCAT:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) &=
~MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_TEST_ENABLE;
break;
case MEMCFG_SECT_PERIMEM_ALL:
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) &=
~MEMCFG_PERI_MEM_TEST_CONTROL_EMAC_TEST_ENABLE;
HWREG(CMMEMCFG_BASE + MEMCFG_O_PERI_MEM_TEST_CONTROL) &=
~MEMCFG_PERI_MEM_TEST_CONTROL_ETHERCAT_TEST_ENABLE;
break;
default:
//
// Do nothing. Invalid memory type.
//
break;
}
}
//*****************************************************************************
//
// MemCfg_getUncorrErrorAddress
//
//*****************************************************************************
uint32_t
MemCfg_getUncorrErrorAddress(uint32_t stsFlag)
{
uint32_t errAddress;
//
// Gets address location of selected uncorrectable read/write error.
//
switch(stsFlag)
{
case MEMCFG_UCERR_M4READ:
case MEMCFG_UCERR_M4WRITE:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCM4EADDR);
break;
case MEMCFG_UCERR_EMACREAD:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCEMACEADDR);
break;
case MEMCFG_UCERR_UDMAREAD:
case MEMCFG_UCERR_UDMAWRITE:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCUDMAEADDR);
break;
case MEMCFG_UCERR_ETHERCATMEMREAD:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCETHERCATMEMREADDR);
break;
case MEMCFG_UCERR_EMACMEMREAD:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCEMACMEMREADDR);
break;
default:
//
// Invalid stsFlag.
//
errAddress = 0x0U;
break;
}
return(errAddress);
}
//*****************************************************************************
//
// MemCfg_getCorrErrorAddress
//
//*****************************************************************************
uint32_t
MemCfg_getCorrErrorAddress(uint32_t stsFlag)
{
uint32_t errAddress;
//
// Gets address location of selected uncorrectable read/write error.
//
switch(stsFlag)
{
case MEMCFG_CERR_M4READ:
case MEMCFG_CERR_M4WRITE:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CM4EADDR);
break;
case MEMCFG_CERR_EMACREAD:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CEMACEADDR);
break;
case MEMCFG_CERR_UDMAREAD:
case MEMCFG_CERR_UDMAWRITE:
errAddress = HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CUDMAEADDR);
break;
default:
//
// Invalid stsFlag.
//
errAddress = 0x0U;
break;
}
return(errAddress);
}
//*****************************************************************************
//
// MemCfg_getBusFaultAddress
//
//*****************************************************************************
uint32_t
MemCfg_getBusFaultAddress(uint32_t busMaster)
{
uint32_t offset, temp;
//
// Calculate the address offset for selected bus master.
//
offset = 0U;
temp = busMaster;
while(temp > 1U)
{
temp = temp >> 1U;
offset += (uint32_t)(MEMCFG_O_UDMABUSFAULTADDR -
MEMCFG_O_M4BUSFAULTADDR);
}
//
// Read and return the bus fault address at the calculated offset.
//
return(HWREG(CMMEMORYERROR_BASE + (uint32_t)MEMCFG_O_M4BUSFAULTADDR +
offset));
}
@@ -0,0 +1,945 @@
//###########################################################################
//
// FILE: memcfg.h
//
// TITLE: CM SRAM config driver.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef MEMCFG_H
#define MEMCFG_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup memcfg_api MemCfg
//! \brief This module is used for CM SRAM configurations.
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memcfg.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "cpu.h"
#include "debug.h"
//*****************************************************************************
//
// Defines for the API.
//
//*****************************************************************************
//*****************************************************************************
//
// Define for specifying the key for writing error registers
//
//*****************************************************************************
#define MEMCFG_KEY 0xA5A50000U //!< Key for error registers
//*****************************************************************************
//
// Masks to decode memory section defines.
//
//*****************************************************************************
#define MEMCFG_SECT_TYPE_MASK 0xFF000000U //!< Mask for section type
#define MEMCFG_SECT_TYPE_CX 0x00000000U //!< Mask for Cx memory
#define MEMCFG_SECT_TYPE_CMMSGX 0x01000000U //!< Mask for CMMSGRAM
#define MEMCFG_SECT_TYPE_SX 0x02000000U //!< Mask for S/Ex memory
#define MEMCFG_SECT_TYPE_ROM 0x03000000U //!< Mask for ROM memory
#define MEMCFG_SECT_TYPE_PERIMEM 0x04000000U //!< Mask for peripheral
//!< memory(EMAC & EtherCAT)
#define MEMCFG_SECT_NUM_MASK 0x00FFFFFFU //!< Mask for selecting the
//!< section number
//*****************************************************************************
//
// Define to specify the mask for memory test mode.
//
//*****************************************************************************
#define MEMCFG_TESTMODE_M MEMCFG_CXTEST_TEST_C0_M //!< Mask for
//!< test mode
//*****************************************************************************
//
// Values that can be passed to MemCfg_lockConfig(), MemCfg_unlockConfig(),
// MemCfg_setTestMode() as memSection(s) parameter; to MemCfg_initSections(),
// MemCfg_getInitStatus() as ramSections parameter; to MemCfg_forceMemError(),
// MemCfg_enablePeriMemTestMode(), MemCfg_disablePeriMemTestMode() as the
// memTypes parameter.
//
//*****************************************************************************
//
// Cx Memories - Dedicated to core CM, accessible on CODE bus.
//
#define MEMCFG_SECT_C0 0x00000001U //!< C0 RAM
#define MEMCFG_SECT_C1 0x00000002U //!< C1 RAM
#define MEMCFG_SECT_CX_ALL 0x00000003U //!< All Cx RAM
//
// CMMSGx Memories - For exchanging data between CM & C28x subsystem.
//
#define MEMCFG_SECT_CMTOCPU1MSGRAM0 0x01000001U //!< CM TO CPU1 MSG RAM0
#define MEMCFG_SECT_CMTOCPU1MSGRAM1 0x01000002U //!< CM TO CPU1 MSG RAM1
#define MEMCFG_SECT_CMTOCPU2MSGRAM0 0x01000004U //!< CM TO CPU2 MSG RAM0
#define MEMCFG_SECT_CMTOCPU2MSGRAM1 0x01000008U //!< CM TO CPU2 MSG RAM1
#define MEMCFG_SECT_CMMSGX_ALL 0x0100000FU //!< All CM MSG RAMs
//
// Sx and Ex Memories - shared between bus masters.
//
#define MEMCFG_SECT_S0 0x02000001U //!< S0 RAM
#define MEMCFG_SECT_S1 0x02000002U //!< S1 RAM
#define MEMCFG_SECT_S2 0x02000004U //!< S2 RAM
#define MEMCFG_SECT_S3 0x02000008U //!< S3 RAM
#define MEMCFG_SECT_E0 0x02000010U //!< E0 RAM
#define MEMCFG_SECT_SX_ALL 0x0200001FU //!< All Sx and Ex RAM
//
// ROM memory - read only
//
#define MEMCFG_SECT_ROM 0x03000001U //!< ROM Section
//
// Peripheral Memories - EMAC & EtherCAT
//
#define MEMCFG_SECT_PERIMEM_EMAC 0x04000002U //!< EMAC memory
#define MEMCFG_SECT_PERIMEM_ETHERCAT 0x04000020U //!< EtherCAT memory
#define MEMCFG_SECT_PERIMEM_ALL 0x04000001U //!< All peripheral memories
//
// All Memory Sections
//
#define MEMCFG_SECT_ALL 0xFFFFFFFFU //!< All memory Sections
//*****************************************************************************
//
// Values that can be passed to MemCfg_forceUncorrErrorStatus(),
// MemCfg_clearUncorrErrorStatus(), MemCfg_getUncorrErrorAddress() as stsFlags
// parameter and returned by MemCfg_getUncorrErrorStatus().
//
//*****************************************************************************
#define MEMCFG_UCERR_M4READ 0x00000001U //!< Uncorr M4 Read Error
#define MEMCFG_UCERR_M4WRITE 0x00000002U //!< Uncorr M4 Write Error
#define MEMCFG_UCERR_EMACREAD 0x00000004U //!< Uncorr EMAC Read Error
#define MEMCFG_UCERR_UDMAREAD 0x00000010U //!< Uncorr uDMA Read Error
#define MEMCFG_UCERR_UDMAWRITE 0x00000020U //!< Uncorr uDMA Write Error
#define MEMCFG_UCERR_ETHERCATMEMREAD 0x00000040U //!< Uncorr ECAT Mem Read
//!< Error
#define MEMCFG_UCERR_EMACMEMREAD 0x00000080U //!< Uncorr EMAC Mem Read
//!< Error
//*****************************************************************************
//
// Values that can be passed to MemCfg_getCorrErrorStatus(),
// MemCfg_forceCorrErrorStatus(), MemCfg_clearCorrErrorStatus(),
// MemCfg_getCorrErrorAddress(), as stsFlag(s) parameter; to
// MemCfg_enableCorrErrorInterrupt(), MemCfg_disableCorrErrorInterrupt(),
// MemCfg_clearCorrErrorInterruptStatus() as intFlags parameter and returned by
// MemCfg_getCorrErrorStatus() and MemCfg_getCorrErrorInterruptStatus().
//
//*****************************************************************************
#define MEMCFG_CERR_M4READ 0x00000001U //!< Corr M4 Read Error
#define MEMCFG_CERR_M4WRITE 0x00000002U //!< Corr M4 Write Error
#define MEMCFG_CERR_EMACREAD 0x00000004U //!< Corr EMAC Read Error
#define MEMCFG_CERR_UDMAREAD 0x00000010U //!< Corr uDMA Read Error
#define MEMCFG_CERR_UDMAWRITE 0x00000020U //!< Corr uDMA Write Error
//*****************************************************************************
//
// Values that can be passed to MemCfg_clearDiagErrorStatus() as stsFlags
// parameter and returned by MemCfg_getDiagErrorStatus().
//
//*****************************************************************************
#define MEMCFG_DIAGERR_UNCORR_READ 0x00000001U //!< Diag Uncorr Read Error
#define MEMCFG_DIAGERR_UNCORR_WRITE 0x00000002U //!< Diag Uncorr Write Error
#define MEMCFG_DIAGERR_CORR_READ 0x00000004U //!< Diag Corr Read Error
#define MEMCFG_DIAGERR_CORR_WRITE 0x00000008U //!< Diag Corr Write Error
//*****************************************************************************
//
// Values that can be passed to MemCfg_getBusFaultAddress(),
// MemCfg_clearBusFaultStatus(), MemCfg_getBusFaultStatus() as busMaster(s)
// parameter.
//
//*****************************************************************************
//
// Select M4 as bus master
//
#define MEMCFG_BUSMASTER_M4 MEMCFG_BUSFAULTFLG_M4BUSFAULT
//
// Select uDMA as bus master
//
#define MEMCFG_BUSMASTER_UDMA MEMCFG_BUSFAULTFLG_UDMABUSFAULT
//
// Select EMAC as bus master
//
#define MEMCFG_BUSMASTER_EMAC MEMCFG_BUSFAULTFLG_EMACBUSFAULT
//
// Select all the bus masters
//
#define MEMCFG_BUSMATER_ALL (MEMCFG_BUSMASTER_M4 | \
MEMCFG_BUSMASTER_UDMA | \
MEMCFG_BUSMASTER_EMAC)
//*****************************************************************************
//
// Values that can be returned by MemCfg_getBusFaultStatus().
//
//*****************************************************************************
//
// M4 access encountered busfault
//
#define MEMCFG_BUSFAULT_M4 MEMCFG_BUSFAULTFLG_M4BUSFAULT
//
// uDMA access encountered busfault
//
#define MEMCFG_BUSFAULT_UDMA MEMCFG_BUSFAULTFLG_UDMABUSFAULT
//
// EMAC access encountered busfault
//
#define MEMCFG_BUSFAULT_EMAC MEMCFG_BUSFAULTFLG_EMACBUSFAULT
//*****************************************************************************
//
//! Values that can be passed to MemCfg_setTestMode() as the \e testMode
//! parameter.
//
//*****************************************************************************
typedef enum
{
MEMCFG_TEST_FUNCTIONAL = 0x0U, //!< Functional mode
MEMCFG_TEST_WRITE_DATA = 0x1U, //!< Writes allowed to data only
MEMCFG_TEST_WRITE_ECC = 0x2U, //!< Writes allowed to ECC only
MEMCFG_TEST_FUNC_DIAG = 0x3U //!< Diagnostic mode, similar to
//!< functional mode but NMI is
//!< not generated
} MemCfg_TestMode;
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
//! Gets the current uncorrectable memory read/write error status.
//!
//! \return Returns the current error status, enumerated as a bit field of
//! \b MEMCFG_UCERR_M4READ, \b MEMCFG_UCERR_M4WRITE, \b MEMCFG_UCERR_EMACREAD,
//! \b MEMCFG_UCERR_UDMAREAD, \b MEMCFG_UCERR_UDMAWRITE,
//! \b MEMCFG_UCERR_ETHERCATMEMREAD or/and \b MEMCFG_UCERR_EMACMEMREAD.
//
//*****************************************************************************
static inline uint32_t
MemCfg_getUncorrErrorStatus(void)
{
//
// Read and return RAM error status flags.
//
return(HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCERRFLG));
}
//*****************************************************************************
//
//! Sets the specified uncorrectable memory read/write error status flag.
//!
//! \param stsFlags is a bit mask of the error sources.
//!
//! This function sets the specified uncorrectable memory read/write error
//! status flag. The \e stsFlags parameter can take any of the following values:
//! \b MEMCFG_UCERR_M4READ, \b MEMCFG_UCERR_M4WRITE, \b MEMCFG_UCERR_EMACREAD,
//! \b MEMCFG_UCERR_UDMAREAD, \b MEMCFG_UCERR_UDMAWRITE,
//! \b MEMCFG_UCERR_ETHERCATMEMREAD or/and \b MEMCFG_UCERR_EMACMEMREAD.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_forceUncorrErrorStatus(uint32_t stsFlags)
{
//
// Write the flags to the appropriate SET register.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCERRSET) = (MEMCFG_KEY | stsFlags);
}
//*****************************************************************************
//
//! Clears uncorrectable memory read/write error flags.
//!
//! \param stsFlags is a bit mask of the status flags to be cleared.
//!
//! This function clears the specified uncorrectable memory read/write error
//! flags. The \e stsFlags parameter can take any of the following values or
//! their logical OR: \b MEMCFG_UCERR_M4READ, \b MEMCFG_UCERR_M4WRITE,
//! \b MEMCFG_UCERR_EMACREAD, \b MEMCFG_UCERR_UDMAREAD,
//! \b MEMCFG_UCERR_UDMAWRITE, \b MEMCFG_UCERR_ETHERCATMEMREAD or/and
//! \b MEMCFG_UCERR_EMACMEMREAD.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_clearUncorrErrorStatus(uint32_t stsFlags)
{
//
// Clear the respective error flags.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_UCERRCLR) = (MEMCFG_KEY | stsFlags);
}
//*****************************************************************************
//
//! Gets the bus fault status of the selected bus master.
//!
//! \param busMasters specifies the bus master for which status is to be
//! returned.
//!
//! This function returns the bus fault status for selected bus masters.The
//! parameter \e busMasters can be logical OR of any of the following values:
//! \b MEMCFG_BUSMASTER_M4, \b MEMCFG_BUSMASTER_UDMA, \b MEMCFG_BUSMASTER_EMAC,
//! or \b MEMCFG_BUSMATER_ALL to get the status for all the bus masters.
//!
//! \return Returns bus fault status of the bus masters. It can return below
//! values or their logical OR's:
//! - \b MEMCFG_BUSFAULT_M4 - M4 access encountered busfault
//! - \b MEMCFG_BUSFAULT_UDMA - uDMA access encountered busfault
//! - \b MEMCFG_BUSFAULT_EMAC - EMAC access encountered busfault
//
//*****************************************************************************
static inline uint32_t
MemCfg_getBusFaultStatus(uint32_t busMasters)
{
//
// Return the bus fault status.
//
return(HWREG(CMMEMORYERROR_BASE + MEMCFG_O_BUSFAULTFLG) & busMasters);
}
//*****************************************************************************
//
//! Clears the bus fault status of the selected bus master.
//!
//! \param busMasters specifies the bus masters for which fault status is to be
//! cleared.
//!
//! This function clears the bus fault status for selected bus masters. The
//! \e busMasters parameter can be logical OR of any of the following values:
//! \b MEMCFG_BUSMASTER_M4, MEMCFG_BUSMASTER_UDMA, MEMCFG_BUSMASTER_EMAC, or
//! \b MEMCFG_BUSMATER_ALL to clear the status for all the bus masters.
//!
//! \return None
//
//*****************************************************************************
static inline void
MemCfg_clearBusFaultStatus(uint32_t busMasters)
{
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_BUSFAULTCLR) =
(MEMCFG_KEY | busMasters);
}
//*****************************************************************************
//
//! Gets the current correctable memory read/write error status.
//!
//! \return Returns the current error status, enumerated as a bit field of
//! \b MEMCFG_CERR_M4READ, \b MEMCFG_CERR_M4WRITE, \b MEMCFG_CERR_EMACREAD,
//! \b MEMCFG_CERR_UDMAREAD, and/or \b MEMCFG_CERR_UDMAWRITE.
//
//*****************************************************************************
static inline uint32_t
MemCfg_getCorrErrorStatus(void)
{
//
// Read and return RAM error status flags.
//
return(HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CERRFLG));
}
//*****************************************************************************
//
//! Sets the specified correctable memory read/write error status flag.
//!
//! \param stsFlags is a bit mask of the error sources.
//!
//! This function sets the specified correctable memory read/write error status
//! flag. The \e stsFlags parameter can take any of the following values:
//! \b MEMCFG_CERR_M4READ, \b MEMCFG_CERR_M4WRITE, \b MEMCFG_CERR_EMACREAD,
//! \b MEMCFG_CERR_UDMAREAD, and/or \b MEMCFG_CERR_UDMAWRITE.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_forceCorrErrorStatus(uint32_t stsFlags)
{
//
// Write the flags to the appropriate SET register.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CERRSET) = (MEMCFG_KEY | stsFlags);
}
//*****************************************************************************
//
//! Clears correctable memory read/write error flags.
//!
//! \param stsFlags is a bit mask of the status flags to be cleared.
//!
//! This function clears the specified correctable memory read/write error
//! flags. The \e stsFlags parameter can take any of the following values:
//! \b MEMCFG_CERR_M4READ, \b MEMCFG_CERR_M4WRITE, \b MEMCFG_CERR_EMACREAD,
//! \b MEMCFG_CERR_UDMAREAD and/or \b MEMCFG_CERR_UDMAWRITE.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_clearCorrErrorStatus(uint32_t stsFlags)
{
//
// Clear the requested flags.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CERRCLR) = (MEMCFG_KEY | stsFlags);
}
//*****************************************************************************
//
//! Gets the correctable error count.
//!
//! \return Returns the number of correctable error which have occurred.
//
//*****************************************************************************
static inline uint32_t
MemCfg_getCorrErrorCount(void)
{
//
// Read and return the number of errors that have occurred.
//
return(HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CERRCNT));
}
//*****************************************************************************
//
//! Sets the correctable error threshold value.
//!
//! \param threshold is the correctable error threshold.
//!
//! This value sets the error-count threshold at which a correctable error
//! interrupt is generated. That is when the error count register reaches the
//! value specified by the \e threshold parameter, an interrupt is
//! generated if it is enabled.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_setCorrErrorThreshold(uint32_t threshold)
{
//
// Write the threshold value to the appropriate register.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CERRTHRES) = threshold;
}
//*****************************************************************************
//
//! Enables correctable error interrupt source.
//!
//! \param intFlags is a bit mask of the interrupt sources to be enabled.
//!
//! This function enables the indicated correctable error interrupt
//! source. Only the sources that are enabled can be reflected to the
//! processor interrupt; disabled sources have no effect on the processor. The
//! param \e intFlags can take the value \b MEMCFG_CERR_M4READ only. Other
//! values are reserved.
//!
//! \note Note that only correctable errors may generate interrupts.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_enableCorrErrorInterrupt(uint32_t intFlags)
{
//
// Enable the specified interrupts.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CEINTEN) = (MEMCFG_KEY | intFlags);
}
//*****************************************************************************
//
//! Disables individual correctable error interrupt sources.
//!
//! \param intFlags is a bit mask of the interrupt sources to be disabled.
//!
//! This function disables the indicated correctable error interrupt
//! sources. Only the sources that are enabled can be reflected to the
//! processor interrupt; disabled sources have no effect on the processor. The
//! param \e intFlags can take the value \b MEMCFG_CERR_M4READ only. Other
//! values are reserved.
//!
//! \note Note that only correctable errors may generate interrupts.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_disableCorrErrorInterrupt(uint32_t intFlags)
{
//
// Disable the specified interrupts.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CEINTEN) = (MEMCFG_KEY | (~(intFlags) &
0x0000FFFFU));
}
//*****************************************************************************
//
//! Gets the current RAM correctable error interrupt status.
//!
//! \return Returns the current error interrupt status. Will return a value of
//! \b MEMCFG_CERR_M4READ if an interrupt has been generated. If not, the
//! function will return 0.
//
//*****************************************************************************
static inline uint32_t
MemCfg_getCorrErrorInterruptStatus(void)
{
//
// Read and return /correctable error interrupt flags.
//
return(HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CEINTFLG));
}
//*****************************************************************************
//
//! Sets the correctable error interrupt status.
//!
//! \param intFlags is a bit mask of the interrupt sources to be set.
//!
//! This function sets the correctable error interrupt flag. The parameter
//! \e intFlags can take the value \b MEMCFG_CERR_M4READ only. Other values are
//! reserved.
//!
//! \note Note that only correctable errors may generate interrupts.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_forceCorrErrorInterrupt(uint32_t intFlags)
{
//
// Write the flags to the appropriate SET register.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CEINTSET) = (MEMCFG_KEY | intFlags);
}
//*****************************************************************************
//
//! Clears the correctable error interrupt status.
//!
//! \param intFlags is a bit mask of the interrupt sources to be cleared. Can
//! take the value \b MEMCFG_CERR_M4READ only. Other values are reserved.
//!
//! This function clears the correctable error interrupt flag.
//!
//! \note Note that only correctable errors may generate interrupts.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_clearCorrErrorInterruptStatus(uint32_t intFlags)
{
//
// Clear the requested flags.
//
HWREG(CMMEMORYERROR_BASE + MEMCFG_O_CEINTCLR) = (MEMCFG_KEY | intFlags);
}
//*****************************************************************************
//
//! Gets the diagnostics corr/uncorr memory error status.
//!
//! \return Returns the diagnostics error status. It can return following
//! values: \b MEMCFG_DIAGERR_UNCORR_READ, \b MEMCFG_DIAGERR_UNCORR_WRITE,
//! \b MEMCFG_DIAGERR_CORR_READ and/or \b MEMCFG_DIAGERR_CORR_WRITE.
//
//*****************************************************************************
static inline uint32_t
MemCfg_getDiagErrorStatus(void)
{
//
// Returns diag error status.
//
return(HWREG(CMMEMORYDIAGERROR_BASE + MEMCFG_O_DIAGERRFLG));
}
//*****************************************************************************
//
//! Clears the diagnostics corr/uncorr memory error status.
//!
//! \param stsFlags is a bit mask of the status flags to be cleared.
//!
//! This function clears the specified diagnostics corr/uncorr memory read/write
//! error flags. The param \e stsFlags can be any of the following values:
//! \b MEMCFG_DIAGERR_UNCORR_READ, \b MEMCFG_DIAGERR_UNCORR_WRITE,
//! \b MEMCFG_DIAGERR_CORR_READ and/or MEMCFG_DIAGERR_CORR_WRITE.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MemCfg_clearDiagErrorStatus(uint32_t stsFlags)
{
//
// Clear diag error status.
//
HWREG(CMMEMORYDIAGERROR_BASE + MEMCFG_O_DIAGERRCLR ) |= stsFlags;
}
//*****************************************************************************
//
//! Gets address location of diagnostics corr/uncorr memory read/write error.
//!
//! \return Return address location of diagnostics corr/uncorr memory
//! read/write error.
//
//*****************************************************************************
static inline uint32_t
MemCfg_getDiagErrorAddress(void)
{
//
// Return diag error address.
//
return(HWREG(CMMEMORYDIAGERROR_BASE + MEMCFG_O_DIAGERRADDR));
}
//*****************************************************************************
//
//! Locks the write to the configuration of specified memory sections.
//!
//! \param memSections is the logical OR of the sections to be configured.
//!
//! This function locks writes to the init and test configuration of RAM
//! sections, test configuration of boot ROM & peripheral(EMAC & EtherCAT)
//! memory sections. That means calling MemCfg_setTestMode(),
//! MemCfg_initSections() for a locked RAM section; MemCfg_setTestMode() for
//! locked BootROM & peripheral memory will have no effect until
//! MemCfg_unlockConfig() is called.
//!
//! The \e ramSections parameter is an OR of one of the following sets of
//! indicators:
//! - \b MEMCFG_SECT_C0 through \b MEMCFG_SECT_C1 or \b MEMCFG_SECT_CX_ALL,
//! - \b MEMCFG_SECT_CMTOCPU1MSGRAM0 through \b MEMCFG_SECT_CMTOCPU2MSGRAM1 or
//! \b MEMCFG_SECT_CMMSGX_ALL,
//! - \b MEMCFG_SECT_S0 through \b MEMCFG_SECT_S3, \b MEMCFG_SECT_E0 or
//! \b MEMCFG_SECT_SX_ALL,
//! - \b MEMCFG_SECT_ROM,
//! - \b MEMCFG_SECT_PERIMEM_ALL,
//! - \b OR use \b MEMCFG_SECT_ALL to configure all possible sections.
//!
//! \return None.
//
//*****************************************************************************
extern void
MemCfg_lockConfig(uint32_t memSections);
//*****************************************************************************
//
//! Unlocks the writes to the configuration of specified memory sections.
//!
//! \param memSections is the logical OR of the sections to be configured.
//!
//! This function unlocks writes to the init and test configuration of RAM
//! sections, test configuration of boot ROM & peripheral(EMAC & EtherCAT)
//! memory sections that has been locked using MemCfg_lockConfig().
//!
//! The \e ramSections parameter is an OR of one of the following sets of
//! indicators:
//! - \b MEMCFG_SECT_C0 through \b MEMCFG_SECT_C1 or \b MEMCFG_SECT_CX_ALL,
//! - \b MEMCFG_SECT_CMTOCPU1MSGRAM0 through \b MEMCFG_SECT_CMTOCPU2MSGRAM1 or
//! \b MEMCFG_SECT_CMMSGX_ALL,
//! - \b MEMCFG_SECT_S0 through \b MEMCFG_SECT_S3, \b MEMCFG_SECT_E0 or
//! \b MEMCFG_SECT_SX_ALL,
//! - \b MEMCFG_SECT_ROM,
//! - \b MEMCFG_SECT_PERIMEM_ALL,
//! - \b OR use \b MEMCFG_SECT_ALL to configure all possible sections.
//!
//! \sa MemCfg_lockConfig()
//!
//! \return None.
//
//*****************************************************************************
extern void
MemCfg_unlockConfig(uint32_t memSections);
//*****************************************************************************
//
//! Sets the test mode of the specified memory section.
//!
//! \param memSection is the memory section to be configured.
//! \param testMode is the test mode selected.
//!
//! This function sets the test mode configuration of the RAM section. The
//! \e testMode parameter can take one of the following values:
//! - \b MEMCFG_TEST_FUNCTIONAL,
//! - \b MEMCFG_TEST_WRITE_DATA,
//! - \b MEMCFG_TEST_WRITE_ECC, or
//! - \b MEMCFG_TEST_FUNC_DIAG
//!
//! The \e ramSection parameter is one of the following indicators:
//! - \b MEMCFG_SECT_C0 through \b MEMCFG_SECT_C1 or \b MEMCFG_SECT_CX_ALL,
//! - \b MEMCFG_SECT_CMTOCPU1MSGRAM0 through \b MEMCFG_SECT_CMTOCPU2MSGRAM1 or
//! \b MEMCFG_SECT_CMMSGX_ALL,
//! - \b MEMCFG_SECT_S0 through \b MEMCFG_SECT_S3, \b MEMCFG_SECT_E0 or
//! \b MEMCFG_SECT_SX_ALL,
//! - \b OR use \b MEMCFG_SECT_ROM.
//!
//! \return None.
//
//*****************************************************************************
extern void
MemCfg_setTestMode(uint32_t memSection, MemCfg_TestMode testMode);
//*****************************************************************************
//
//! Starts the initialization the specified RAM sections.
//!
//! \param ramSections is the logical OR of the sections to be initialized.
//!
//! This function starts the initialization of the specified RAM sections. Use
//! MemCfg_getInitStatus() to check if the initialization is done.
//!
//! The \e ramSections parameter is an OR of one of the following sets of
//! indicators:
//! - \b MEMCFG_SECT_C0 through \b MEMCFG_SECT_C1 or \b MEMCFG_SECT_CX_ALL,
//! - \b MEMCFG_SECT_CMTOCPU1MSGRAM0 through \b MEMCFG_SECT_CMTOCPU2MSGRAM1 or
//! \b MEMCFG_SECT_CMMSGX_ALL,
//! - \b MEMCFG_SECT_S0 through \b MEMCFG_SECT_S3, \b MEMCFG_SECT_E0 or
//! \b MEMCFG_SECT_SX_ALL,
//! - \b OR use \b MEMCFG_SECT_ALL to configure all possible sections.
//!
//! \return None.
//
//*****************************************************************************
extern void
MemCfg_initSections(uint32_t ramSections);
//*****************************************************************************
//
//! Get the status of initialized RAM sections.
//!
//! \param ramSections is the logical OR of the sections to be checked.
//!
//! This function gets the initialization status of the RAM sections specified
//! by the \e ramSections parameter.
//!
//! The \e ramSections parameter is an OR of one of the following sets of
//! indicators:
//! - \b MEMCFG_SECT_C0 through \b MEMCFG_SECT_C1 or \b MEMCFG_SECT_CX_ALL,
//! - \b MEMCFG_SECT_CMTOCPU1MSGRAM0 through \b MEMCFG_SECT_CMTOCPU2MSGRAM1 or
//! \b MEMCFG_SECT_CMMSGX_ALL,
//! - \b MEMCFG_SECT_S0 through \b MEMCFG_SECT_S3, \b MEMCFG_SECT_E0 or
//! \b MEMCFG_SECT_SX_ALL,
//! - \b OR use \b MEMCFG_SECT_ALL to configure all possible sections.
//!
//! \note Use MemCfg_initSections() to start the initialization.
//!
//! \return Returns \b true if all the sections specified by \e ramSections
//! have been initialized and \b false if not.
//
//*****************************************************************************
extern bool
MemCfg_getInitStatus(uint32_t ramSections);
//*****************************************************************************
//
//! Forces parity error in the selected memory.
//!
//! \param memTypes is the logical OR of the sections to be tested.
//!
//! This function forces the parity error in the memories specified
//! by the \e memTypes parameter.
//!
//! The \e memTypes parameter is an OR of one of the following sets of
//! indicators:
//! - \b MEMCFG_SECT_ROM,
//! - \b MEMCFG_SECT_PERIMEM_EMAC,
//! - \b MEMCFG_SECT_PERIMEM_ETHERCAT, or
//! - \b OR use \b MEMCFG_SECT_ALL to get status of all possible sections.
//!
//! \return None.
//
//*****************************************************************************
extern void
MemCfg_forceMemError(uint32_t memTypes);
//*****************************************************************************
//
//! Enables test mode for selected peripheral memories.
//!
//! \param memTypes is the logical OR of the memories to be tested.
//!
//! This function enables test mode for selected peripheral memories specified
//! by the \e memTypes parameter.
//!
//! The \e memTypes parameter is an OR of one of the following sets of
//! indicators:
//! - \b MEMCFG_SECT_PERIMEM_EMAC,
//! - \b MEMCFG_SECT_PERIMEM_ETHERCAT, or
//! - \b MEMCFG_SECT_PERIMEM_ALL
//!
//! \return None.
//
//*****************************************************************************
extern void
MemCfg_enablePeriMemTestMode(uint32_t memTypes);
//*****************************************************************************
//
//! Disables the test mode for selected peripheral memories.
//!
//! \param memTypes is the logical OR of the memories to be tested.
//!
//! This function disables test mode for selected peripheral memories specified
//! by the \e memTypes parameter.
//!
//! The \e memTypes parameter is an OR of one of the following sets of
//! indicators:
//! - \b MEMCFG_SECT_PERIMEM_EMAC,
//! - \b MEMCFG_SECT_PERIMEM_ETHERCAT, or
//! - \b MEMCFG_SECT_PERIMEM_ALL
//!
//! \return None.
//
//*****************************************************************************
extern void
MemCfg_disablePeriMemTestMode(uint32_t memTypes);
//*****************************************************************************
//
//! Gets the address location of uncorrectable memory read/write error.
//!
//! \param stsFlag is the error for which address needs to be returned.
//!
//! This function returns the address location of uncorrectable read/write
//! error for the specified error. The parameter \e stsFlag can be any of the
//! \b MEMCFG_UCERR_M4READ, \b MEMCFG_UCERR_M4WRITE, \b MEMCFG_UCERR_EMACREAD,
//! \b MEMCFG_UCERR_EMACWRITE,\b MEMCFG_UCERR_UDMAREAD,
//! \b MEMCFG_UCERR_UDMAWRITE, \b MEMCFG_UCERR_ETHERCATMEMREAD or/and
//! \b MEMCFG_UCERR_EMACMEMREAD values.
//!
//! \return Return address location of uncorrectable read/write error.
//
//*****************************************************************************
extern uint32_t
MemCfg_getUncorrErrorAddress(uint32_t stsFlag);
//*****************************************************************************
//
//! Gets the address location of correctable memory read/write error.
//!
//! \param stsFlag is the error for which address needs to be returned.
//!
//! This function returns the address location of correctable read/write
//! error for the specified error. The param \e stsFlag can take any of the
//! \b MEMCFG_CERR_M4READ, \b MEMCFG_CERR_M4WRITE, \b MEMCFG_CERR_EMACREAD,
//! MEMCFG_CERR_EMACWRITE, \b MEMCFG_CERR_UDMAREAD and/or
//! \b MEMCFG_CERR_UDMAWRITE values.
//!
//! \return Return address location of correctable read/write error.
//
//*****************************************************************************
extern uint32_t
MemCfg_getCorrErrorAddress(uint32_t stsFlag);
//*****************************************************************************
//
//! Gets the bus fault address for the selected bus master.
//!
//! \param busMaster specifies the bus masters for which fault address is to be
//! returned.
//!
//! This function return the bus fault address for selected bus master. The
//! parameter \e busMaster can be any of the following values:
//! \b MEMCFG_BUSMASTER_M4, MEMCFG_BUSMASTER_UDMA, or MEMCFG_BUSMASTER_EMAC.
//!
//! \return Returns bus fault address for the selected bus master.
//
//*****************************************************************************
extern uint32_t
MemCfg_getBusFaultAddress(uint32_t busMaster);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // MEMCFG_H
@@ -0,0 +1,44 @@
//###########################################################################
//
// FILE: mpu.c
//
// TITLE: Driver for the memory protection unit (MPU).
//
//###########################################################################
//
// 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 "mpu.h"
@@ -0,0 +1,644 @@
//###########################################################################
//
// FILE: mpu.h
//
// TITLE: Driver for the memory protection unit (MPU).
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef MPU_H
#define MPU_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup mpu_api MPU
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "debug.h"
#include "interrupt.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
//*****************************************************************************
//
// Defines for the API.
//
//*****************************************************************************
//*****************************************************************************
//
// Values that can be passed to MPU_enable() as config parameter.
//
//*****************************************************************************
#define MPU_CONFIG_PRIV_DEFAULT 0x4U //!< Enable default memory map as bg
//!< region for priv sw access.
#define MPU_CONFIG_HARDFLT_NMI 0x2U //!< MPU is enabled during hard fault,
//!< NMI and FAULTMASK handlers.
#define MPU_CONFIG_NONE 0x0U //!< None of the above configurations.
//*****************************************************************************
//
// Values that can be passed to MPU_setRegionAttributes() and
// MPU_getRegionAttributes() as regionNum parameter.
//
//*****************************************************************************
#define MPU_RGN_0 0x0U
#define MPU_RGN_1 0x1U
#define MPU_RGN_2 0x2U
#define MPU_RGN_3 0x3U
#define MPU_RGN_4 0x4U
#define MPU_RGN_5 0x5U
#define MPU_RGN_6 0x6U
#define MPU_RGN_7 0x7U
//*****************************************************************************
//
// Flags for the region size to be passed to MPU_setRegionAttributes().
//
//*****************************************************************************
#define MPU_RGN_SIZE_32B (4U << 1U) //!< Region Size is 32-bytes
#define MPU_RGN_SIZE_64B (5U << 1U) //!< Region Size is 64-bytes
#define MPU_RGN_SIZE_128B (6U << 1U) //!< Region Size is 128-bytes
#define MPU_RGN_SIZE_256B (7U << 1U) //!< Region Size is 256-bytes
#define MPU_RGN_SIZE_512B (8U << 1U) //!< Region Size is 512-bytes
#define MPU_RGN_SIZE_1K (9U << 1U) //!< Region Size is 1K-bytes
#define MPU_RGN_SIZE_2K (10U << 1U) //!< Region Size is 2K-bytes
#define MPU_RGN_SIZE_4K (11U << 1U) //!< Region Size is 4K-bytes
#define MPU_RGN_SIZE_8K (12U << 1U) //!< Region Size is 8K-bytes
#define MPU_RGN_SIZE_16K (13U << 1U) //!< Region Size is 16K-bytes
#define MPU_RGN_SIZE_32K (14U << 1U) //!< Region Size is 32K-bytes
#define MPU_RGN_SIZE_64K (15U << 1U) //!< Region Size is 64K-bytes
#define MPU_RGN_SIZE_128K (16U << 1U) //!< Region Size is 128K-bytes
#define MPU_RGN_SIZE_256K (17U << 1U) //!< Region Size is 256K-bytes
#define MPU_RGN_SIZE_512K (18U << 1U) //!< Region Size is 512K-bytes
#define MPU_RGN_SIZE_1M (19U << 1U) //!< Region Size is 1M-bytes
#define MPU_RGN_SIZE_2M (20U << 1U) //!< Region Size is 2M-bytes
#define MPU_RGN_SIZE_4M (21U << 1U) //!< Region Size is 4M-bytes
#define MPU_RGN_SIZE_8M (22U << 1U) //!< Region Size is 8M-bytes
#define MPU_RGN_SIZE_16M (23U << 1U) //!< Region Size is 16M-bytes
#define MPU_RGN_SIZE_32M (24U << 1U) //!< Region Size is 32M-bytes
#define MPU_RGN_SIZE_64M (25U << 1U) //!< Region Size is 64M-bytes
#define MPU_RGN_SIZE_128M (26U << 1U) //!< Region Size is 128M-bytes
#define MPU_RGN_SIZE_256M (27U << 1U) //!< Region Size is 256M-bytes
#define MPU_RGN_SIZE_512M (28U << 1U) //!< Region Size is 512M-bytes
#define MPU_RGN_SIZE_1G (29U << 1U) //!< Region Size is 1G-bytes
#define MPU_RGN_SIZE_2G (30U << 1U) //!< Region Size is 2G-bytes
#define MPU_RGN_SIZE_4G (31U << 1U) //!< Region Size is 4G-bytes
//*****************************************************************************
//
// Flags for the permissions to be passed to MPU_setRegionAttributes().
//
//*****************************************************************************
#define MPU_RGN_PERM_EXEC 0x00000000U //!< Inst. fetches are enabled
#define MPU_RGN_PERM_NOEXEC 0x10000000U //!< Inst. fetches are disabled
#define MPU_RGN_PERM_PRV_NO_USR_NO 0x00000000U //!< No access to privileged &
//!< unprivileged access
#define MPU_RGN_PERM_PRV_RW_USR_NO 0x01000000U //!< R/W to privileged sw, no
//!< access to unprivileged sw
#define MPU_RGN_PERM_PRV_RW_USR_RO 0x02000000U //!< R/W access to priv sw, no
//!< access to unpriv sw
#define MPU_RGN_PERM_PRV_RW_USR_RW 0x03000000U //!< R/W access to priv sw, R/W
//!< access to unpriv sw
#define MPU_RGN_PERM_PRV_RO_USR_NO 0x05000000U //!< RO access to priv sw, no
//!< access to unpriv sw
#define MPU_RGN_PERM_PRV_RO_USR_RO 0x06000000U //!< RO access to priv sw, RO
//!< access to unpriv sw
//*****************************************************************************
//
// Flags for the sub-region to be passed to MPU_setRegionAttributes().
//
//*****************************************************************************
#define MPU_SUB_RGN_DISABLE_0 0x00000100U //!< Disable sub-region 0
#define MPU_SUB_RGN_DISABLE_1 0x00000200U //!< Disable sub-region 1
#define MPU_SUB_RGN_DISABLE_2 0x00000400U //!< Disable sub-region 2
#define MPU_SUB_RGN_DISABLE_3 0x00000800U //!< Disable sub-region 3
#define MPU_SUB_RGN_DISABLE_4 0x00001000U //!< Disable sub-region 4
#define MPU_SUB_RGN_DISABLE_5 0x00002000U //!< Disable sub-region 5
#define MPU_SUB_RGN_DISABLE_6 0x00004000U //!< Disable sub-region 6
#define MPU_SUB_RGN_DISABLE_7 0x00008000U //!< Disable sub-region 7
//*****************************************************************************
//
// Flags to enable or disable a region, to be passed to
// MPU_setRegionAttributes().
//
//*****************************************************************************
#define MPU_RGN_ENABLE 1U //!< Enable MPU Region
#define MPU_RGN_DISABLE 0U //!< Disable MPU Region
//*****************************************************************************
//
// Mask for MPU region attributes to be used by MPU_setRegionAttributes().
//
//*****************************************************************************
#define MPU_RGN_CONFIG_M ((uint32_t)NVIC_MPU_RASR_ENABLE | \
(uint32_t)NVIC_MPU_RASR_SIZE_M | \
(uint32_t)NVIC_MPU_RASR_SRD_M | \
(uint32_t)NVIC_MPU_RASR_B | \
(uint32_t)NVIC_MPU_RASR_C | \
(uint32_t)NVIC_MPU_RASR_S | \
(uint32_t)NVIC_MPU_RASR_TEX_M | \
(uint32_t)NVIC_MPU_RASR_AP_M | \
(uint32_t)NVIC_MPU_RASR_XN)
//*****************************************************************************
//
// API Function prototypes
//
//*****************************************************************************
//*****************************************************************************
//
//! Enables and configures the MPU for use.
//!
//! \param config is the logical OR of the possible configurations.
//!
//! This function enables the Cortex-M memory protection unit. It also
//! configures the default behavior when in privileged mode and while handling
//! a hard fault or NMI. Prior to enabling the MPU, at least one region must
//! be set by calling MPU_setRegionAttributes() or else by enabling the default
//! region for privileged mode by passing the \b MPU_CONFIG_PRIV_DEFAULT flag
//! to MPU_enable(). Once the MPU is enabled, a memory management fault is
//! generated for memory access violations.
//!
//! The \e config parameter should be the logical OR of any of the
//! following:
//! - \b MPU_CONFIG_PRIV_DEFAULT enables the default memory map when in
//! privileged mode and when no other regions are defined. If this option
//! is not enabled, then there must be at least one valid region already
//! defined when the MPU is enabled.
//! - \b MPU_CONFIG_HARDFLT_NMI enables the MPU while in a hard fault or NMI
//! exception handler. If this option is not enabled, then the MPU is
//! disabled while in one of these exception handlers and the default
//! memory map is applied.
//! - \b MPU_CONFIG_NONE chooses none of the above options. In this case,
//! no default memory map is provided in privileged mode, and the MPU is not
//! enabled in the fault handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_enable(uint32_t config)
{
//
// Check the arguments.
//
ASSERT((config & ~(MPU_CONFIG_PRIV_DEFAULT |
MPU_CONFIG_HARDFLT_NMI)) == 0U);
//
// Set the MPU control bits according to the flags passed by the user,
// and also set the enable bit.
//
HWREG(NVIC_BASE + NVIC_O_MPU_CTRL) |= (config | NVIC_MPU_CTRL_ENABLE);
}
//*****************************************************************************
//
//! Disables the MPU for use.
//!
//! \param None
//!
//! This function disables the Cortex-M memory protection unit. When the
//! MPU is disabled, the default memory map is used and memory management
//! faults are not generated.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_disable(void)
{
//
// Turn off the MPU enable bit.
//
HWREG(NVIC_BASE + NVIC_O_MPU_CTRL) &= ~NVIC_MPU_CTRL_ENABLE;
}
//*****************************************************************************
//
//! Gets the count of regions supported by the MPU.
//!
//! \param None
//!
//! This function is used to get the total number of regions that are supported
//! by the MPU, including regions that are already programmed.
//!
//! \return The number of memory protection regions that are available
//! for programming using MPU_setRegionAttributes().
//
//*****************************************************************************
static inline uint32_t
MPU_getRegionCount(void)
{
//
// Read the DREGION field of the MPU type register and mask off
// the bits of interest to get the count of regions.
//
return((HWREG(NVIC_BASE + NVIC_O_MPU_TYPE) & NVIC_MPU_TYPE_DREGION_M) >>
NVIC_MPU_TYPE_DREGION_S);
}
//*****************************************************************************
//
//! Enables a specific region.
//!
//! \param regionNum is the region number to enable.
//!
//! This function is used to enable a memory protection region. The region
//! should already be configured with the MPU_setRegionAttributes() function.
//! Once enabled, the memory protection rules of the region are applied and
//! access violations cause a memory management fault.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_enableRegion(uint32_t regionNum)
{
//
// Check the arguments.
//
ASSERT(regionNum < 8U);
//
// Select the region to modify.
//
HWREG(NVIC_BASE + NVIC_O_MPU_RNR) = (HWREG(NVIC_BASE + NVIC_O_MPU_RNR) &
~NVIC_MPU_RNR_REGION_M) | regionNum;
//
// Modify the enable bit in the region attributes.
//
HWREG(NVIC_BASE + NVIC_O_MPU_RASR) |= NVIC_MPU_RASR_ENABLE;
}
//*****************************************************************************
//
//! Disables a specific region.
//!
//! \param regionNum is the region number to disable.
//!
//! This function is used to disable a previously enabled memory protection
//! region. The region remains configured if it is not overwritten with
//! another call to MPU_setRegionAttributes(), and can be enabled again by
//! calling MPU_enableRegion().
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_disableRegion(uint32_t regionNum)
{
//
// Check the arguments.
//
ASSERT(regionNum < 8U);
//
// Select the region to modify.
//
HWREG(NVIC_BASE + NVIC_O_MPU_RNR) = (HWREG(NVIC_BASE + NVIC_O_MPU_RNR) &
~NVIC_MPU_RNR_REGION_M) | regionNum;
//
// Modify the enable bit in the region attributes.
//
HWREG(NVIC_BASE + NVIC_O_MPU_RASR) &= ~NVIC_MPU_RASR_ENABLE;
}
//*****************************************************************************
//
//! Sets up the access rules for a specific region.
//!
//! \param regionNum is the region number to set up.
//! \param baseAddr is the base address of the region. It must be aligned
//! according to the size of the region specified in attrFlags.
//! \param attrFlags is a set of flags to define the attributes of the region.
//!
//! This function sets up the protection rules for a region. The region has
//! a base address and a set of attributes including the size.
//!
//! The region number parameter, \e regionNum specifies the region number to be
//! setup. Valid values for \e regionNum parameter are:
//! - \b MPU_RGN_0
//! - \b MPU_RGN_1
//! - \b MPU_RGN_2
//! - \b MPU_RGN_3
//! - \b MPU_RGN_4
//! - \b MPU_RGN_5
//! - \b MPU_RGN_6
//! - \b MPU_RGN_7
//!
//! The base address parameter, \e baseAddr, must be aligned according to the
//! size, and the size must be a power of 2.
//!
//! The \e attrFlags parameter is the logical OR of all of the attributes
//! of the region. It is a combination of choices for region size,
//! execute permission, read/write permissions, disabled sub-regions,
//! and a flag to determine if the region is enabled.
//!
//! The size flag determines the size of a region and must be one of the
//! following:
//! - \b MPU_RGN_SIZE_32B
//! - \b MPU_RGN_SIZE_64B
//! - \b MPU_RGN_SIZE_128B
//! - \b MPU_RGN_SIZE_256B
//! - \b MPU_RGN_SIZE_512B
//! - \b MPU_RGN_SIZE_1K
//! - \b MPU_RGN_SIZE_2K
//! - \b MPU_RGN_SIZE_4K
//! - \b MPU_RGN_SIZE_8K
//! - \b MPU_RGN_SIZE_16K
//! - \b MPU_RGN_SIZE_32K
//! - \b MPU_RGN_SIZE_64K
//! - \b MPU_RGN_SIZE_128K
//! - \b MPU_RGN_SIZE_256K
//! - \b MPU_RGN_SIZE_512K
//! - \b MPU_RGN_SIZE_1M
//! - \b MPU_RGN_SIZE_2M
//! - \b MPU_RGN_SIZE_4M
//! - \b MPU_RGN_SIZE_8M
//! - \b MPU_RGN_SIZE_16M
//! - \b MPU_RGN_SIZE_32M
//! - \b MPU_RGN_SIZE_64M
//! - \b MPU_RGN_SIZE_128M
//! - \b MPU_RGN_SIZE_256M
//! - \b MPU_RGN_SIZE_512M
//! - \b MPU_RGN_SIZE_1G
//! - \b MPU_RGN_SIZE_2G
//! - \b MPU_RGN_SIZE_4G
//!
//! The execute permission flag must be one of the following:
//! - \b MPU_RGN_PERM_EXEC enables the region for execution of code
//! - \b MPU_RGN_PERM_NOEXEC disables the region for execution of code
//!
//! The read/write access permissions are applied separately for the
//! privileged and user modes. The read/write access flags must be one
//! of the following:
//! - \b MPU_RGN_PERM_PRV_NO_USR_NO - no access in privileged or user mode
//! - \b MPU_RGN_PERM_PRV_RW_USR_NO - privileged read/write, user no access
//! - \b MPU_RGN_PERM_PRV_RW_USR_RO - privileged read/write, user read-only
//! - \b MPU_RGN_PERM_PRV_RW_USR_RW - privileged read/write, user read/write
//! - \b MPU_RGN_PERM_PRV_RO_USR_NO - privileged read-only, user no access
//! - \b MPU_RGN_PERM_PRV_RO_USR_RO - privileged read-only, user read-only
//!
//! The region is automatically divided into 8 equally-sized sub-regions by
//! the MPU. Sub-regions can only be used in regions of size 256 bytes
//! or larger. Any of these 8 sub-regions can be disabled, allowing for
//! creation of ``holes'' in a region which can be left open, or overlaid
//! by another region with different attributes. Any of the 8 sub-regions
//! can be disabled with a logical OR of any of the following flags:
//! - \b MPU_SUB_RGN_DISABLE_0
//! - \b MPU_SUB_RGN_DISABLE_1
//! - \b MPU_SUB_RGN_DISABLE_2
//! - \b MPU_SUB_RGN_DISABLE_3
//! - \b MPU_SUB_RGN_DISABLE_4
//! - \b MPU_SUB_RGN_DISABLE_5
//! - \b MPU_SUB_RGN_DISABLE_6
//! - \b MPU_SUB_RGN_DISABLE_7
//!
//! Finally, the region can be initially enabled or disabled with one of
//! the following flags:
//! - \b MPU_RGN_ENABLE
//! - \b MPU_RGN_DISABLE
//!
//! As an example, to set a region with the following attributes: size of
//! 32 KB, execution enabled, read-only for both privileged and user, one
//! sub-region disabled, and initially enabled; the \e attrFlags parameter
//! would have the following value:
//!
//! <code>
//! (MPU_RGN_SIZE_32K | MPU_RGN_PERM_EXEC | MPU_RGN_PERM_PRV_RO_USR_RO |
//! MPU_SUB_RGN_DISABLE_2 | MPU_RGN_ENABLE)
//! </code>
//!
//! \note This function writes to multiple registers and is not protected
//! from interrupts. It is possible that an interrupt which accesses a
//! region may occur while that region is in the process of being changed.
//! The safest way to handle this is to disable a region before changing it.
//! Refer to the discussion of this in the API Detailed Description section.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_setRegionAttributes(uint32_t regionNum, uint32_t baseAddr,
uint32_t attrFlags)
{
uint32_t temp;
//
// Check the arguments.
//
ASSERT(regionNum < 8U);
//
// Checking whether the region base address is aligned according to the
// desired region size.
//
ASSERT(baseAddr == (baseAddr & (~(uint32_t)0U <<
(((attrFlags & NVIC_MPU_RASR_SIZE_M) >>
NVIC_MPU_RASR_SIZE_S) + 1U))));
//
// Select region to be configured.
//
HWREG(NVIC_BASE + NVIC_O_MPU_RNR) = (regionNum & NVIC_MPU_RNR_REGION_M) >>
NVIC_MPU_RNR_REGION_S;
//
// Program the region attributes.
//
temp = MPU_RGN_CONFIG_M;
HWREG(NVIC_BASE + NVIC_O_MPU_RASR) = (HWREG(NVIC_BASE + NVIC_O_MPU_RASR) &
~(temp)) | attrFlags;
//
// Program the base address of the region.
//
HWREG(NVIC_BASE + NVIC_O_MPU_RBAR) = baseAddr;
}
//*****************************************************************************
//
//! Gets the current settings for a specific region.
//!
//! \param regionNum is the region number to get.
//! \param baseAddr points to storage for the base address of the region.
//! \param attrFlags points to the attribute flags for the region.
//!
//! This function retrieves the configuration of a specific region. The
//! meanings and format of the parameters is the same as that of the
//! MPU_setRegionAttributes() function.
//!
//! This function can be used to save the configuration of a region for later
//! use with the MPU_setRegionAttributes() function. The region's enable state
//! is preserved in the attributes that are saved.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_getRegionAttributes(uint32_t regionNum, uint32_t *baseAddr,
uint32_t *attrFlags)
{
//
// Check the arguments.
//
ASSERT(regionNum < 8U);
ASSERT(baseAddr != 0U);
ASSERT(attrFlags != 0U);
//
// Select the region to get.
//
HWREG(NVIC_BASE + NVIC_O_MPU_RNR) = regionNum;
//
// Read and store the base address for the region.
//
*baseAddr = HWREG(NVIC_BASE + NVIC_O_MPU_RBAR) & NVIC_MPU_RBAR_ADDR_M;
//
// Read and store the region attributes.
//
*attrFlags = HWREG(NVIC_BASE + NVIC_O_MPU_RASR);
}
//*****************************************************************************
//
//! Registers an interrupt handler for the memory management fault.
//!
//! \param intNum is the interrupt number to be registered.
//! \param fnHandler is a pointer to the function to be called when the
//! memory management fault occurs.
//!
//! This function sets and enables the handler to be called when the MPU
//! generates a memory management fault due to a protection region access
//! violation. The param intNum can take value FAULT_MPU.
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_registerHandler(uint32_t intNum, void (*fnHandler)(void))
{
//
// Check the arguments.
//
ASSERT(fnHandler);
//
// Register the interrupt handler.
//
Interrupt_registerHandler(intNum, fnHandler);
//
// Enable the memory management fault.
//
Interrupt_enable(intNum);
}
//*****************************************************************************
//
//! Unregisters an interrupt handler for the memory management fault.
//!
//! \param intNum is the interrupt number to be unregistered.
//!
//! This function disables and clears the handler to be called when a
//! memory management fault occurs. The param intNum can take value FAULT_MPU.
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
MPU_unregisterHandler(uint32_t intNum)
{
//
// Disable the interrupt.
//
Interrupt_disable(intNum);
//
// Unregister the interrupt handler.
//
Interrupt_unregisterHandler(intNum);
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // MPU_H
@@ -0,0 +1,63 @@
//###########################################################################
//
// FILE: platform_port.c
// TITLE: CM Subsystem Platform Port layer
//
// Version History Details:
// 22- Apr- 19: Initial Version
//###########################################################################
//
// 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 "platform_port.h"
void Platform_enablePeripheral(uint32_t peripheral)
{
SysCtl_enablePeripheral((SysCtl_PeripheralPCLOCKCR)peripheral);
}
void Platform_resetPeripheral(uint32_t peripheral)
{
SysCtl_resetPeripheral((SysCtl_PeripheralSOFTPRES)peripheral);
}
void Platform_enableInterrupt(uint32_t interruptNum)
{
Interrupt_enable(interruptNum);
}
void Platform_disableInterrupt(uint32_t interruptNum)
{
Interrupt_disable(interruptNum);
}
@@ -0,0 +1,76 @@
//###########################################################################
//
// FILE: platform_port.h
// TITLE: CM Subsystem Platform Port layer
//
// Version History Details:
// 22- Apr- 19: Initial Version
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef PLATFORM_PORT_H
#define PLATFORM_PORT_H
#include <stdint.h>
#include "inc/hw_types.h"
#include "sysctl.h"
#include "interrupt.h"
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
extern void Platform_enablePeripheral(uint32_t peripheral);
extern void Platform_resetPeripheral(uint32_t peripheral);
extern void Platform_enableInterrupt(uint32_t interruptNum);
extern void Platform_disableInterrupt(uint32_t interruptNum);
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // __PLATFORM_PORT_H__
@@ -0,0 +1,216 @@
//###########################################################################
//
// FILE: ssi.c
//
// TITLE: Driver for the SSI module.
//
//###########################################################################
//
// 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 "ssi.h"
//*****************************************************************************
//
// SSI_setConfig
//
//*****************************************************************************
void SSI_setConfig(uint32_t base, uint32_t ssiClk, uint32_t protocol,
uint32_t mode, uint32_t bitRate, uint32_t dataWidth)
{
uint32_t maxBitRate;
uint32_t preDiv;
uint32_t scr;
uint32_t sph_spo;
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
ASSERT((protocol == SSI_FRF_MOTO_MODE_0) ||
(protocol == SSI_FRF_MOTO_MODE_1) ||
(protocol == SSI_FRF_MOTO_MODE_2) ||
(protocol == SSI_FRF_MOTO_MODE_3) ||
(protocol == SSI_FRF_TI));
ASSERT((mode == SSI_MODE_MASTER) ||
(mode == SSI_MODE_SLAVE));
ASSERT(((mode == SSI_MODE_MASTER) && (bitRate <= (ssiClk / 2U))) ||
((mode != SSI_MODE_MASTER) && (bitRate <= (ssiClk / 12U))));
ASSERT((ssiClk / bitRate) <= (254U * 256U));
ASSERT((dataWidth >= 4U) && (dataWidth <= 16U));
//
// Set the mode.
//
HWREG(base + SSI_O_CR1) = ((mode == SSI_MODE_MASTER) ? 0U : SSI_CR1_MS);
//
// Set the clock predivider.
//
maxBitRate = ssiClk / bitRate;
preDiv = 0U;
do
{
preDiv += 2U;
scr = (maxBitRate / preDiv) - 1U;
}
while(scr > 255U);
HWREG(base + SSI_O_CPSR) = preDiv;
//
// Set protocol and clock rate.
//
sph_spo = (protocol & 3U) << 6U;
HWREG(base + SSI_O_CR0) = (scr << 8U) | sph_spo |
(protocol & SSI_CR0_FRF_M) |
(dataWidth - 1U);
}
//*****************************************************************************
//
// SSI_writeData
//
//*****************************************************************************
void SSI_writeData(uint32_t base, uint32_t data)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
ASSERT((data & (0xFFFFFFFEU << (HWREG(base + SSI_O_CR0) &
SSI_CR0_DSS_M))) == 0U);
//
// Wait until there is space.
//
while((HWREG(base + SSI_O_SR) & SSI_SR_TNF) == 0U)
{
}
//
// Write the data to the SSI.
//
HWREG(base + SSI_O_DR) = data;
}
//*****************************************************************************
//
// SSI_writeDataNonBlocking
//
//*****************************************************************************
int32_t SSI_writeDataNonBlocking(uint32_t base, uint32_t data)
{
int32_t retVal;
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
ASSERT((data & (0xFFFFFFFEU << (HWREG(base + SSI_O_CR0) &
SSI_CR0_DSS_M))) == 0U);
//
// Check for space to write.
//
if((HWREG(base + SSI_O_SR) & SSI_SR_TNF) != 0U)
{
HWREG(base + SSI_O_DR) = data;
retVal = 1;
}
else
{
retVal = 0;
}
return(retVal);
}
//*****************************************************************************
//
// SSI_readData
//
//*****************************************************************************
void SSI_readData(uint32_t base, uint32_t *dataPtr)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Wait until there is data to be read.
//
while((HWREG(base + SSI_O_SR) & SSI_SR_RNE) == 0U)
{
}
//
// Read data from SSI.
//
*dataPtr = HWREG(base + SSI_O_DR);
}
//*****************************************************************************
//
// SSI_readDataNonBlocking
//
//*****************************************************************************
int32_t SSI_readDataNonBlocking(uint32_t base, uint32_t *dataPtr)
{
int32_t retVal;
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Check for data to read.
//
if((HWREG(base + SSI_O_SR) & SSI_SR_RNE) != 0U)
{
*dataPtr = HWREG(base + SSI_O_DR);
retVal = 1;
}
else
{
retVal = 0;
}
return(retVal);
}
@@ -0,0 +1,774 @@
//###########################################################################
//
// FILE: ssi.h
//
// TITLE: Driver for the SSI module.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef SSI_H
#define SSI_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup ssi_api SSI
//! \brief This module is used for SSI configurations.
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "debug.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_ssi.h"
#include "interrupt.h"
//*****************************************************************************
//
// Defines for the API.
//
//*****************************************************************************
//*****************************************************************************
//
// Values that can be passed to SSI_enableInterrupt, SSI_disableInterrupt,
// and SSI_clearInterruptStatus as the interrupts parameter,
// and returned by SSI_getInterruptStatus.
//
//*****************************************************************************
#define SSI_INT_TXEOT 0x00000040U // Transmit FIFO is empty
#define SSI_INT_DMATX 0x00000020U // DMA Transmit complete
#define SSI_INT_DMARX 0x00000010U // DMA Receive complete
#define SSI_INT_TXFF 0x00000008U // TX FIFO half full or less
#define SSI_INT_RXFF 0x00000004U // RX FIFO half full or more
#define SSI_INT_RXTO 0x00000002U // RX timeout
#define SSI_INT_RXOR 0x00000001U // RX overrun
//*****************************************************************************
//
// Values that can be passed to SSI_setConfig.
//
//*****************************************************************************
#define SSI_FRF_MOTO_MODE_0 0x00000000U // Moto/Freescale fmt, pol 0, ph 0
#define SSI_FRF_MOTO_MODE_1 0x00000002U // Moto/Freescale fmt, pol 0, ph 1
#define SSI_FRF_MOTO_MODE_2 0x00000001U // Moto/Freescale fmt, pol 1, ph 0
#define SSI_FRF_MOTO_MODE_3 0x00000003U // Moto/Freescale fmt, pol 1, ph 1
#define SSI_FRF_TI 0x00000010U // TI frame format
#define SSI_MODE_MASTER 0x00000000U // SSI master
#define SSI_MODE_SLAVE 0x00000001U // SSI slave
//*****************************************************************************
//
// Values that can be passed to SSI_enableDMA() and SSI_disableDMA().
//
//*****************************************************************************
#define SSI_DMA_TX 0x00000002U // Enable DMA for transmit
#define SSI_DMA_RX 0x00000001U // Enable DMA for receive
//*****************************************************************************
//
// API Function prototypes
//
//*****************************************************************************
//*****************************************************************************
//
//! \internal
//! Checks an SSI base address.
//!
//! \param base specifies the SSI module base address.
//!
//! This function determines if a SSI module base address is valid.
//!
//! \return Returns \b true if the base address is valid and \b false
//! otherwise.
//
//*****************************************************************************
#ifdef DEBUG
static inline bool
SSI_isBaseValid(uint32_t base)
{
return(base == SSI0_BASE);
}
#endif
//*****************************************************************************
//
//! Enables the synchronous serial interface.
//!
//! \param base specifies the SSI module base address.
//!
//! This function enables operation of the synchronous serial interface. The
//! synchronous serial interface must be configured before it is enabled.
//!
//! \note The function SSI_setConfig() must be called before calling
//! SSI_enableModule() function
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_enableModule(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Read-modify-write the enable bit.
//
HWREG(base + SSI_O_CR1) |= SSI_CR1_SSE;
}
//*****************************************************************************
//
//! Disables the synchronous serial interface.
//!
//! \param base specifies the SSI module base address.
//!
//! This function disables operation of the synchronous serial interface.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_disableModule(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Read-modify-write the enable bit.
//
HWREG(base + SSI_O_CR1) &= ~(SSI_CR1_SSE);
}
//*****************************************************************************
//
//! Registers an interrupt handler for the synchronous serial interface.
//!
//! \param intNum specifies the SSI interrupt number
//! \param pfnHandler is a pointer to the function to be called when the
//! SSI interrupt occurs.
//!
//! This function registers the handler to be called when an SSI interrupt
//! occurs. This function enables the global interrupt in the interrupt
//! controller; specific SSI interrupts must be enabled via
//! SSI_enableInterrupt(). If necessary, it is the interrupt handler's
//! responsibility to clear the interrupt source via SSI_clearInterruptStatus().
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_registerInterrupt(uint32_t intNum, void (*pfnHandler)(void))
{
//
// Register the interrupt handler, returning an error if an error occurs.
//
Interrupt_registerHandler(intNum, pfnHandler);
//
// Enable the synchronous serial interface interrupt.
//
Interrupt_enable(intNum);
}
//*****************************************************************************
//
//! Unregisters an interrupt handler for the synchronous serial interface.
//!
//! \param intNum specifies the SSI interrupt number
//!
//! This function clears the handler to be called when an SSI interrupt
//! occurs. This function also masks off the interrupt in the interrupt
//! controller so that the interrupt handler no longer is called.
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_unregisterInterrupt(uint32_t intNum)
{
//
// Disable the interrupt.
//
Interrupt_disable(intNum);
//
// Unregister the interrupt handler.
//
Interrupt_unregisterHandler(intNum);
}
//*****************************************************************************
//
//! Enables individual SSI interrupt sources.
//!
//! \param base specifies the SSI module base address.
//! \param interrupts is a bit mask of the interrupt sources to be enabled.
//!
//! This function enables the indicated SSI interrupt sources.
//! Only the sources that are enabled can be reflected to the processor
//! interrupt; disabled sources have no effect on the processor.
//! The \e interrupts parameter can be any of the \\b SSI_INT_TXEOT,
//! \b SSI_INT_DMATX, \b SSI_INT_DMARX, \b SSI_INT_TXFF, \b SSI_INT_RXFF,
//! \b SSI_INT_RXTO, or \b SSI_INT_RXOR values.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_enableInterrupt(uint32_t base, uint32_t interrupts)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Enable the specified interrupts.
//
HWREG(base + SSI_O_IM) |= interrupts;
}
//*****************************************************************************
//
//! Disables individual SSI interrupt sources.
//!
//! \param base specifies the SSI module base address.
//! \param interrupts is a bit mask of the interrupt sources to be disabled.
//!
//! This function disables the indicated SSI interrupt sources. The
//! \e interrupts parameter can be any of the \b SSI_INT_TXEOT,
//! \b SSI_INT_DMATX, \b SSI_INT_DMARX, \b SSI_INT_TXFF, \b SSI_INT_RXFF,
//! \b SSI_INT_RXTO, or \b SSI_INT_RXOR values.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_disableInterrupt(uint32_t base, uint32_t interrupts)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Disable the specified interrupts.
//
HWREG(base + SSI_O_IM) &= ~(interrupts);
}
//*****************************************************************************
//
//! Gets the current interrupt status.
//!
//! \param base specifies the SSI module base address.
//! \param masked is \b false if the raw interrupt status is required or
//! \b true if the masked interrupt status is required.
//!
//! This function returns the interrupt status for the SSI module. Either the
//! raw interrupt status or the status of interrupts that are allowed to
//! reflect to the processor can be returned.
//!
//! \return The current interrupt status, enumerated as a bit field of
//! \b SSI_INT_TXEOT, \b SSI_INT_DMATX, b SSI_INT_DMARX, \b SSI_INT_TXFF,
//! \b SSI_INT_RXFF, \b SSI_RXTO, or \b SSI_RXOR
//
//*****************************************************************************
static inline uint32_t
SSI_getInterruptStatus(uint32_t base, bool masked)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Return either the interrupt status or the raw interrupt status as
// requested.
//
return(masked ? HWREG(base + SSI_O_MIS) : HWREG(base + SSI_O_RIS));
}
//*****************************************************************************
//
//! Clears SSI interrupt sources.
//!
//! \param base specifies the SSI module base address.
//! \param interrupts is a bit mask of the interrupt sources to be cleared.
//!
//! This function clears the specified SSI interrupt sources so that they no
//! longer assert. This function must be called in the interrupt handler to
//! keep the interrupts from being triggered again immediately upon exit. The
//! \e interrupts parameter can consist of either or both the \b SSI_RXTO and
//! \b SSI_RXOR values.
//!
//! \note Because there is a write buffer in the Cortex-M processor, it may
//! take several clock cycles before the interrupt source is actually cleared.
//! Therefore, it is recommended that the interrupt source be cleared early in
//! the interrupt handler (as opposed to the very last action) to avoid
//! returning from the interrupt handler before the interrupt source is
//! actually cleared. Failure to do so may result in the interrupt handler
//! being immediately reentered (because the interrupt controller still sees
//! the interrupt source asserted).
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_clearInterruptStatus(uint32_t base, uint32_t interrupts)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Clear the requested interrupt sources.
//
HWREG(base + SSI_O_ICR) = interrupts;
}
//*****************************************************************************
//
//! Enables SSI DMA operation.
//!
//! \param base is the base address of the SSI module.
//! \param dmaFlags is a bit mask of the DMA features to enable.
//!
//! This function enables the specified SSI DMA features. The SSI can be
//! configured to use DMA for transmit and/or receive data transfers.
//! The \e dmaFlags parameter is the logical OR of any of the following
//! values:
//!
//! - SSI_DMA_RX - enable DMA for receive
//! - SSI_DMA_TX - enable DMA for transmit
//!
//! \note The uDMA controller must also be set up before DMA can be used
//! with the SSI.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_enableDMA(uint32_t base, uint32_t dmaFlags)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Set the requested bits in the SSI DMA control register.
//
HWREG(base + SSI_O_DMACTL) |= dmaFlags;
}
//*****************************************************************************
//
//! Disables SSI DMA operation.
//!
//! \param base is the base address of the SSI module.
//! \param dmaFlags is a bit mask of the DMA features to disable.
//!
//! This function is used to disable SSI DMA features that were enabled
//! by SSI_enableDMA(). The specified SSI DMA features are disabled. The
//! \e dmaFlags parameter is the logical OR of any of the following values:
//!
//! - SSI_DMA_RX - disable DMA for receive
//! - SSI_DMA_TX - disable DMA for transmit
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_disableDMA(uint32_t base, uint32_t dmaFlags)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Clear the requested bits in the SSI DMA control register.
//
HWREG(base + SSI_O_DMACTL) &= ~dmaFlags;
}
//*****************************************************************************
//
//! Determines whether the SSI transmitter is busy or not.
//!
//! \param base is the base address of the SSI module.
//!
//! This function allows the caller to determine whether all transmitted bytes
//! have cleared the transmitter hardware. If \b false is returned, then the
//! transmit FIFO is empty and all bits of the last transmitted word have left
//! the hardware shift register.
//!
//! \return Returns \b true if the SSI is transmitting or \b false if all
//! transmissions are complete.
//
//*****************************************************************************
static inline bool
SSI_isBusy(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Determine if the SSI is busy.
//
return(((HWREG(base + SSI_O_SR) & SSI_SR_BSY) == SSI_SR_BSY));
}
//*****************************************************************************
//
//! Enables internal loopback mode for SSI.
//!
//! \param base is the base address of the SSI module.
//!
//! This function configures SSI port in internal loopback mode to help with
//! diagnostics and debug. In this mode, Output of the transmit serial
//! shift register is connected internally to the input of the receive
//! serial shift register.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_enableLoopback(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Enable loopback
//
HWREG(base + SSI_O_CR1) |= SSI_CR1_LBM;
}
//*****************************************************************************
//
//! Disables internal loopback mode for SSI.
//!
//! \param base is the base address of the SSI module.
//!
//! This function is used to disable SSI internal loopback that was enabled by
//! SSI_enableLoopback().
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_disableLoopback(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Enable loopback
//
HWREG(base + SSI_O_CR1) &= ~SSI_CR1_LBM;
}
//*****************************************************************************
//
//! Enables the Fss hold feature
//!
//! \param base is the base address of the SSI module.
//!
//! This function configures the SSI module to hold the FSS low when there is
//! available data in the Tx FIFO. The Fss signal is de-asserted when the Tx
//! FIFO is empty
//!
//! \note This feature is not available in TI frame format. It is only
//! available in Freescale frame format.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_enableFssHold(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Set the hold frame bit.
//
HWREG(base + SSI_O_CR1) |= SSI_CR1_FSSHLDFRM;
}
//*****************************************************************************
//
//! Disables the Fss hold feature
//!
//! \param base is the base address of the SSI module.
//!
//! This function configures the SSI module to de-assert the SSIFss signal
//! for one SSI clock cycle after every byte is transferred.
//! This mode is the default operation.
//!
//! \note This feature is not available in TI frame format. It is only
//! available in Freescale frame format.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SSI_disableFssHold(uint32_t base)
{
//
// Check the arguments.
//
ASSERT(SSI_isBaseValid(base));
//
// Clear the hold frame bit.
//
HWREG(base + SSI_O_CR1) &= ~(SSI_CR1_FSSHLDFRM);
}
//*****************************************************************************
//
//! Configures the synchronous serial interface.
//!
//! \param base specifies the SSI module base address.
//! \param ssiClk is the rate of the clock supplied to the SSI module.
//! \param protocol specifies the data transfer protocol.
//! \param mode specifies the mode of operation.
//! \param bitRate specifies the clock rate.
//! \param dataWidth specifies number of bits transferred per frame.
//!
//! This function configures the synchronous serial interface. It sets
//! the SSI protocol, mode of operation, bit rate, and data width.
//!
//! The \e protocol parameter defines the data frame format. The
//! \e protocol parameter can be one of the following values:
//! \b SSI_FRF_MOTO_MODE_0, \b SSI_FRF_MOTO_MODE_1, \b SSI_FRF_MOTO_MODE_2,
//! \b SSI_FRF_MOTO_MODE_3 or \b SSI_FRF_TI.
//! The Motorola/Freescale frame formats encode the following polarity and phase
//! configurations:
//!
//! <pre>
//! Polarity Phase mode
//! 0 0 SSI_FRF_MOTO_MODE_0
//! 0 1 SSI_FRF_MOTO_MODE_1
//! 1 0 SSI_FRF_MOTO_MODE_2
//! 1 1 SSI_FRF_MOTO_MODE_3
//! </pre>
//!
//! The \e mode parameter defines the operating mode of the SSI module.
//! The SSI module can operate as a master or slave. The \e mode parameter
//! can be one of the following values: \b SSI_MODE_MASTER or \b SSI_MODE_SLAVE.
//!
//! The \e bitRate parameter defines the bit rate for the SSI. This bit
//! rate must satisfy the following clock ratio criteria:
//!
//! - ssiClk >= 2 * bit rate (master mode)
//! - ssiClk >= 12 * bit rate (slave modes)
//!
//! where ssiClk is the frequency of the clock supplied to the SSI module. Note
//! that there are frequency limits for FSSI that are described in the Bit Rate
//! Generation section of the SSI chapter in the data sheet.
//!
//! The \e dataWidth parameter defines the width of the data transfers and
//! can be a value between 4 and 16, inclusive.
//!
//! The peripheral clock is the same as the processor clock. The macro
//! CM_CLK_FREQ from sysctl.h can be used as the parameter
//!
//! \return None.
//
//*****************************************************************************
extern void
SSI_setConfig(uint32_t base, uint32_t ssiClk, uint32_t protocol,
uint32_t mode, uint32_t bitRate, uint32_t dataWidth);
//*****************************************************************************
//
//! Puts a data element into the SSI transmit FIFO.
//!
//! \param base specifies the SSI module base address.
//! \param data is the data to be transmitted over the SSI interface.
//!
//! This function places the supplied data into the transmit FIFO of the
//! specified SSI module. If there is no space available in the transmit FIFO,
//! this function waits until there is space available before returning.
//!
//! \note The upper 32 - N bits of \e data are discarded by the hardware,
//! where N is the data width as configured by SSI_setConfig(). For
//! example, if the interface is configured for 8-bit data width, the upper 24
//! bits of \e data are discarded.
//!
//! \return None.
//
//*****************************************************************************
extern void
SSI_writeData(uint32_t base, uint32_t data);
//*****************************************************************************
//
//! Puts a data element into the SSI transmit FIFO.
//!
//! \param base specifies the SSI module base address.
//! \param data is the data to be transmitted over the SSI interface.
//!
//! This function places the supplied data into the transmit FIFO of the
//! specified SSI module. If there is no space in the FIFO, then this function
//! returns a zero.
//!
//! \note The upper 32 - N bits of \e data are discarded by the hardware,
//! where N is the data width as configured by SSI_setConfig(). For
//! example, if the interface is configured for 8-bit data width, the upper 24
//! bits of \e data are discarded.
//!
//! \return Returns the number of elements written to the SSI transmit FIFO.
//
//*****************************************************************************
extern int32_t
SSI_writeDataNonBlocking(uint32_t base, uint32_t data);
//*****************************************************************************
//
//! Gets a data element from the SSI receive FIFO.
//!
//! \param base specifies the SSI module base address.
//! \param dataPtr is a pointer to a storage location for data that was
//! received over the SSI interface.
//!
//! This function gets received data from the receive FIFO of the specified
//! SSI module and places that data into the location specified by the
//! \e dataPtr parameter. If there is no data available, this function waits
//! until data is received before returning.
//!
//! \note Only the lower N bits of the value written to \e dataPtr contain
//! valid data, where N is the data width as configured by
//! SSI_setConfig(). For example, if the interface is configured for
//! 8-bit data width, only the lower 8 bits of the value written to
//! \e dataPtr contain valid data.
//!
//! \return None.
//
//*****************************************************************************
extern void
SSI_readData(uint32_t base, uint32_t *dataPtr);
//*****************************************************************************
//
//! Gets a data element from the SSI receive FIFO.
//!
//! \param base specifies the SSI module base address.
//! \param dataPtr is a pointer to a storage location for data that was
//! received over the SSI interface.
//!
//! This function gets received data from the receive FIFO of the specified SSI
//! module and places that data into the location specified by the \e data
//! parameter. If there is no data in the FIFO, then this function returns a
//! zero.
//!
//! \note Only the lower N bits of the value written to \e dataPtr contain
//! valid data, where N is the data width as configured by
//! SSI_setConfig(). For example, if the interface is configured for
//! 8-bit data width, only the lower 8 bits of the value written to
//! \e dataPtr contain valid data.
//!
//! \return Returns the number of elements read from the SSI receive FIFO.
//
//*****************************************************************************
extern int32_t
SSI_readDataNonBlocking(uint32_t base, uint32_t *dataPtr);
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // SSI_H
@@ -0,0 +1,264 @@
//###########################################################################
//
// FILE: sysctl.c
//
// TITLE: CM system control driver.
//
//###########################################################################
//
// 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 "sysctl.h"
//*****************************************************************************
//
// SysCtl_delay()
//
//*****************************************************************************
//
//SYSCTL_DELAY define for delay of fixed cycles.
//
SYSCTL_DELAY
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
//*****************************************************************************
//
// SysCtl_resetPeripheral()
//
//*****************************************************************************
void
SysCtl_resetPeripheral(SysCtl_PeripheralSOFTPRES peripheral)
{
uint16_t regIndex;
uint16_t bitIndex;
uint32_t clearvalue;
//
// Decode the peripheral variable.
//
regIndex = (uint16_t)4U * ((uint16_t)peripheral &
(uint16_t)SYSCTL_PERIPH_REG_M);
bitIndex = ((uint16_t)peripheral & SYSCTL_PERIPH_BIT_M) >>
SYSCTL_PERIPH_BIT_S;
//
//Write will succeed only if a matching key value is written
//to the KEY field
//Sets the appropriate reset bit and then clears it.
//
HWREG(CMSYSCTL_BASE + SYSCTL_O_CMSOFTPRESET0 + regIndex) |=
(((uint32_t)1U << bitIndex) |
(((uint32_t)SYSCTL_CMSYSCTL_KEY << 16U ) &
SYSCTL_CMSOFTPRESET0_KEY_M));
clearvalue = HWREG(CMSYSCTL_BASE + SYSCTL_O_CMSOFTPRESET0 + regIndex);
clearvalue &= ~((uint32_t)1U << bitIndex);
HWREG(CMSYSCTL_BASE + SYSCTL_O_CMSOFTPRESET0 + regIndex) =
(((uint32_t)SYSCTL_CMSYSCTL_KEY << 16U) &
SYSCTL_CMPCLKCR0_KEY_M) | clearvalue;
}
//*****************************************************************************
//
// SysCtl_enablePeripheral()
//
//*****************************************************************************
void
SysCtl_enablePeripheral(SysCtl_PeripheralPCLOCKCR peripheral)
{
uint16_t regIndex;
uint16_t bitIndex;
//
// Decode the peripheral variable.
//
regIndex = (uint16_t)4U * ((uint16_t)peripheral &
(uint16_t)SYSCTL_PERIPH_REG_M);
bitIndex = ((uint16_t)peripheral & SYSCTL_PERIPH_BIT_M) >>
SYSCTL_PERIPH_BIT_S;
//
// Write will succeed only if a matching key value is written to
// the KEY field
// Turn on the module clock.
//
HWREG(CMSYSCTL_BASE + SYSCTL_O_CMPCLKCR0 + regIndex) |=
(((uint32_t)1U << bitIndex) |
(((uint32_t)SYSCTL_CMSYSCTL_KEY << 16U ) &
SYSCTL_CMPCLKCR0_KEY_M));
}
//*****************************************************************************
//
// SysCtl_disablePeripheral()
//
//*****************************************************************************
void
SysCtl_disablePeripheral(SysCtl_PeripheralPCLOCKCR peripheral)
{
uint16_t regIndex;
uint16_t bitIndex;
uint32_t clearvalue;
//
// Decode the peripheral variable.
//
regIndex = (uint16_t)4U * ((uint16_t)peripheral &
(uint16_t)SYSCTL_PERIPH_REG_M);
bitIndex = ((uint16_t)peripheral & SYSCTL_PERIPH_BIT_M) >>
SYSCTL_PERIPH_BIT_S;
//
//Write will succeed only if a matching key value is written
// to the KEY field
// Turn off the module clock.
//
clearvalue = HWREG(CMSYSCTL_BASE + SYSCTL_O_CMPCLKCR0 + regIndex);
clearvalue &= ~((uint32_t)1U << bitIndex);
HWREG(CMSYSCTL_BASE + SYSCTL_O_CMPCLKCR0 + regIndex) =
(((uint32_t)SYSCTL_CMSYSCTL_KEY << 16U) &
SYSCTL_CMPCLKCR0_KEY_M) | clearvalue;
}
//*****************************************************************************
//
// SysCtl_requestPeripheralClockStop()
//
//*****************************************************************************
void
SysCtl_requestPeripheralClockStop(SysCtl_PeripheralCMCLKSTOPREQ peripheral,
uint16_t enable)
{
uint16_t regIndex;
uint16_t bitIndex;
uint32_t clearvalue;
//
// Decode the peripheral variable.
//
regIndex = (uint16_t)4U * ((uint16_t)peripheral &
(uint16_t)SYSCTL_PERIPH_REG_M);
bitIndex = ((uint16_t)peripheral & SYSCTL_PERIPH_BIT_M) >>
SYSCTL_PERIPH_BIT_S;
//
//Write will succeed only if a matching key value is written
//to the KEY field
// Request to stop the clock
//
if(enable == 1U) //enable the peripheral clock Stop
{
HWREG(CMSYSCTL_BASE + SYSCTL_O_CMCLKSTOPREQ0 + regIndex) |=
(((uint32_t)1U << bitIndex) |
(((uint32_t)SYSCTL_CMSYSCTL_KEY << 16U) &
SYSCTL_CMCLKSTOPREQ0_KEY_M));
}
else //disable the peripheral clock Stop
{
clearvalue = HWREG(CMSYSCTL_BASE + SYSCTL_O_CMCLKSTOPREQ0 + regIndex);
clearvalue &= ~((uint32_t)1U << bitIndex);
HWREG(CMSYSCTL_BASE + SYSCTL_O_CMCLKSTOPREQ0 + regIndex) =
(((uint32_t)SYSCTL_CMSYSCTL_KEY << 16U) &
SYSCTL_CMCLKSTOPREQ0_KEY_M) | clearvalue;
}
}
//*****************************************************************************
//
// SysCtl_isPeripheralClockStopAcked()
//
//*****************************************************************************
bool
SysCtl_isPeripheralClockStopAcked(SysCtl_PeripheralCMCLKSTOPACK peripheral)
{
uint16_t regIndex;
uint16_t bitIndex;
//
// Decode the peripheral variable.
//
regIndex = (uint16_t)4U * ((uint16_t)peripheral &
(uint16_t)SYSCTL_PERIPH_REG_M);
bitIndex = ((uint16_t)peripheral & SYSCTL_PERIPH_BIT_M) >>
SYSCTL_PERIPH_BIT_S;
//
// Read the register and return true if the clk stop Req is acked or not.
//
return((HWREGH(CMSYSCTL_BASE + SYSCTL_O_CMCLKSTOPACK1 + regIndex) &
((uint32_t)1U << bitIndex)) != 0U);
}
//*****************************************************************************
//
// SysCtl_getPeripheralClockStop()
//
//*****************************************************************************
uint16_t
SysCtl_getPeripheralClockStop(SysCtl_PeripheralCMCLKSTOPREQ peripheral)
{
uint16_t regIndex;
//
// Decode the peripheral variable.
//
regIndex = (uint16_t)4U * ((uint16_t)peripheral &
(uint16_t)SYSCTL_PERIPH_REG_M);
//
// Read the register and return the value of clk stop Req
//
return(HWREGH(CMSYSCTL_BASE + SYSCTL_O_CMCLKSTOPREQ0 + regIndex));
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,44 @@
//###########################################################################
//
// FILE: systick.c
//
// TITLE: Driver for the Systick module.
//
//###########################################################################
//
// 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 "systick.h"
@@ -0,0 +1,342 @@
//###########################################################################
//
// FILE: systick.h
//
// TITLE: Driver for the Systick module.
//
//###########################################################################
//
// 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.
// $
//###########################################################################
#ifndef SYSTICK_H
#define SYSTICK_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup systick_api SysTick
//! \brief This module is used for configurating Systick.
//! @{
//
//*****************************************************************************
#include <stdbool.h>
#include <stdint.h>
#include "debug.h"
#include "interrupt.h"
#include "inc/hw_ints.h"
#include "inc/hw_memmap.h"
#include "inc/hw_nvic.h"
#include "inc/hw_types.h"
//*****************************************************************************
//
//! Values that can be passed to SYSTICK_setClockSource() as the
//! \e clkSrc parameter.
//
//*****************************************************************************
typedef enum
{
SYSTICK_CLOCK_SOURCE_EXTERNAL = 0x0U, //!< External clock is used
SYSTICK_CLOCK_SOURCE_INTERNAL = 0x4U, //!< Internal clock is used
} SYSTICK_ClockSource;
//*****************************************************************************
//
//! Sets the clokc source for SysTick counter.
//!
//! \param clkSrc specifies the clock source type.
//!
//! This function sets the clokc source for SysTick counter. The Systick clock
//! can be set as either internal clock or external. The param clkSrc can
//! take following values:SYSTICK_CLOCK_SOURCE_EXTERNAL and
//! SYSTICK_CLOCK_SOURCE_INTERNAL.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_setClockSource(SYSTICK_ClockSource clkSrc)
{
//
// Sets SysTick clock source.
//
HWREG(NVIC_BASE + NVIC_O_SYST_CSR) = (HWREG(NVIC_BASE + NVIC_O_SYST_CSR) &
~NVIC_SYST_CSR_CLKSOURCE) |
(uint32_t)clkSrc;
}
//*****************************************************************************
//
//! Enables the SysTick counter.
//!
//! This function starts the SysTick counter. If an interrupt handler has been
//! registered, it is called when the SysTick counter rolls over.
//!
//! \note Calling this function causes the SysTick counter to (re)commence
//! counting from its current value. The counter is not automatically reloaded
//! with the period as specified in a previous call to SysTick_setPeriod(). If
//! an immediate reload is required, the \b NVIC_O_SYST_CVR register must be
//! written to force the reload. Any write to this register clears the SysTick
//! counter to 0 and causes a reload with the supplied period on the next
//! clock.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_enableCounter(void)
{
//
// Enable SysTick Counter.
//
HWREG(NVIC_BASE + NVIC_O_SYST_CSR) |= NVIC_SYST_CSR_ENABLE;
}
//*****************************************************************************
//
//! Disables the SysTick counter.
//!
//! This function stops the SysTick counter. If an interrupt handler has been
//! registered, it is not called until SysTick is restarted.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_disableCounter(void)
{
//
// Disable SysTick Counter.
//
HWREG(NVIC_BASE + NVIC_O_SYST_CSR) &= ~NVIC_SYST_CSR_ENABLE;
}
//*****************************************************************************
//
//! Sets the period of the SysTick counter.
//!
//! \param period is the number of clock ticks in each period of the
//! SysTick counter and must be between 1 and 16,777,216, inclusive.
//!
//! This function sets the rate at which the SysTick counter wraps, which
//! equates to the number of processor clocks between interrupts.
//!
//! \note Calling this function does not cause the SysTick counter to reload
//! immediately. If an immediate reload is required, the \b NVIC_O_SYST_CVR
//! register must be written. Any write to this register clears the SysTick
//! counter to 0 and causes a reload with the \e period supplied here on
//! the next clock after SysTick is enabled.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_setPeriod(uint32_t period)
{
//
// Check the arguments.
//
ASSERT((period > 0) && (period <= 0x1000000U));
//
// Set the period of the SysTick counter.
//
HWREG(NVIC_BASE + NVIC_O_SYST_RVR) = period - 1U;
}
//*****************************************************************************
//
//! Gets the period of the SysTick counter.
//!
//! This function returns the rate at which the SysTick counter wraps, which
//! equates to the number of processor clocks between interrupts.
//!
//! \return Returns the period of the SysTick counter.
//
//*****************************************************************************
static inline uint32_t
SYSTICK_getPeriod(void)
{
//
// Return the period of the SysTick counter.
//
return(HWREG(NVIC_BASE + NVIC_O_SYST_RVR) + 1U);
}
//*****************************************************************************
//
//! Gets the current value of the SysTick counter.
//!
//! This function returns the current value of the SysTick counter, which is
//! a value between the period - 1 and zero, inclusive.
//!
//! \return Returns the current value of the SysTick counter.
//
//*****************************************************************************
static inline uint32_t
SYSTICK_getCurrentValue(void)
{
//
// Return the current value of the SysTick counter.
//
return(HWREG(NVIC_BASE + NVIC_O_SYST_CVR));
}
//*****************************************************************************
//
//! Enables the SysTick interrupt.
//!
//! This function enables the SysTick interrupt, allowing it to be
//! reflected to the processor.
//!
//! \note The SysTick interrupt handler is not required to clear the SysTick
//! interrupt source because it is cleared automatically by the NVIC when the
//! interrupt handler is called.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_enableInterrupt(void)
{
//
// Enable the SysTick interrupt.
//
Interrupt_enable(FAULT_SYSTICK);
}
//*****************************************************************************
//
//! Disables the SysTick interrupt.
//!
//! This function disables the SysTick interrupt, preventing it from being
//! reflected to the processor.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_disableInterrupt(void)
{
//
// Disable the SysTick interrupt.
//
Interrupt_disable(FAULT_SYSTICK);
}
//*****************************************************************************
//
//! Registers an interrupt handler for the SysTick interrupt.
//!
//! \param fnHandler is a pointer to the function to be called when the
//! SysTick interrupt occurs.
//!
//! This function registers the handler to be called when a SysTick interrupt
//! occurs.
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_registerInterruptHandler(void (*fnHandler)(void))
{
//
// Register the interrupt handler, returning an error if an error occurs.
//
Interrupt_registerHandler(FAULT_SYSTICK, fnHandler);
//
// Enable the SysTick interrupt.
//
Interrupt_enable(FAULT_SYSTICK);
}
//*****************************************************************************
//
//! Unregisters the interrupt handler for the SysTick interrupt.
//!
//! This function unregisters the handler to be called when a SysTick interrupt
//! occurs.
//!
//! \sa Interrupt_registerHandler() for important information about registering
//! interrupt handlers.
//!
//! \return None.
//
//*****************************************************************************
static inline void
SYSTICK_unregisterInterruptHandler(void)
{
//
// Disable the SysTick interrupt.
//
Interrupt_disable(FAULT_SYSTICK);
//
// Unregister the interrupt handler.
//
Interrupt_unregisterHandler(FAULT_SYSTICK);
}
//*****************************************************************************
//
// Close the Doxygen group.
//! @}
//
//*****************************************************************************
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // SYSTICK_H
@@ -0,0 +1,331 @@
//###########################################################################
//
// FILE: uart.c
//
// TITLE: CM UARTdriver.
//
//###########################################################################
//
// 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 <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_uart.h"
#include "debug.h"
#include "interrupt.h"
#include "uart.h"
//*****************************************************************************
//
// API Function prototypes
//
//*****************************************************************************
//*****************************************************************************
//
// UART_setConfig()
//
//*****************************************************************************
void
UART_setConfig(uint32_t base, uint32_t uartClk,
uint32_t baud, uint32_t config)
{
uint32_t divider, baudrt;
baudrt = baud;
//
// Check the arguments.
//
ASSERT(UART_isBaseValid(base));
ASSERT(baudrt != 0U);
ASSERT(uartClk >= (baudrt * UART_CLK_DIVIDER));
//
// Stop the UART.
//
UART_disableModule(base);
//
// Is the required baud rate greater than the maximum rate supported
// without the use of high speed mode?
//
if((baudrt * 16U) > uartClk)
{
//
// Enable high speed mode.
//
HWREG(base + UART_O_CTL) |= UART_CTL_HSE;
//
// Half the supplied baud rate to compensate for enabling high speed
// mode. This allows the following code to be common to both cases.
//
baudrt /= 2U;
}
else
{
//
// Disable high speed mode.
//
HWREG(base + UART_O_CTL) &= ~(UART_CTL_HSE);
}
//
// Compute the fractional baud rate divider.
//
divider = (((uartClk * 8U) / baudrt) + 1U) / 2U;
//
// Set the baud rate.
//
HWREG(base + UART_O_IBRD) = divider / 64U;
HWREG(base + UART_O_FBRD) = divider % 64U;
//
// Set parity, data length, and number of stop bits.
//
HWREG(base + UART_O_LCRH) = config;
//
// Start the UART.
//
UART_enableModule(base);
}
//*****************************************************************************
//
// UART_getConfig()
//
//*****************************************************************************
void
UART_getConfig(uint32_t base, uint32_t uartClk,
uint32_t *baud, uint32_t *config)
{
uint32_t integr, frac;
//
// Check the arguments.
//
ASSERT(UART_isBaseValid(base));
//
// Compute the baud rate.
//
integr = HWREG(base + UART_O_IBRD);
frac = HWREG(base + UART_O_FBRD);
*baud = (uartClk * 4U) / ((64U * integr) + frac);
//
// See if high speed mode enabled.
//
if((HWREG(base + UART_O_CTL) & UART_CTL_HSE) == UART_CTL_HSE)
{
//
// High speed mode is enabled so the actual baud rate is actually
// double what was just calculated.
//
*baud *= 2U;
}
//
// Get the parity, data length, and number of stop bits.
//
*config = (HWREG(base + UART_O_LCRH) &
(UART_LCRH_SPS | UART_LCRH_WLEN_M | UART_LCRH_STP2 |
UART_LCRH_EPS | UART_LCRH_PEN));
}
//*****************************************************************************
//
// UART_writeCharNonBlocking()
//
//*****************************************************************************
bool
UART_writeCharNonBlocking(uint32_t base, uint8_t data)
{
bool ret;
//
// Check the arguments.
//
ASSERT(UART_isBaseValid(base));
//
// See if there is space in the transmit FIFO.
//
if((HWREG(base + UART_O_FR) & UART_FR_TXFF) == 0U)
{
//
// Write this character to the transmit FIFO.
//
HWREG(base + UART_O_DR) = data;
//
// Success.
//
ret = true;
}
else
{
//
// There is no space in the transmit FIFO, so return a failure.
//
ret = false;
}
return(ret);
}
//*****************************************************************************
//
// UART_send9BitAddress()
//
//*****************************************************************************
void
UART_send9BitAddress(uint32_t base, uint8_t addr)
{
uint32_t lcrh;
//
// Check the arguments.
//
ASSERT(UART_isBaseValid(base));
//
// Wait until the FIFO is empty and the UART is not busy.
//
while((HWREG(base + UART_O_FR) & (UART_FR_TXFE | UART_FR_BUSY)) !=
UART_FR_TXFE)
{
}
//
// Force the address/data bit to 1 to indicate this is an address byte.
//
lcrh = HWREG(base + UART_O_LCRH);
HWREG(base + UART_O_LCRH) = ((lcrh & ~UART_LCRH_EPS) |
UART_LCRH_SPS | UART_LCRH_PEN);
//
// Send the address.
//
HWREG(base + UART_O_DR) = addr;
//
// Wait until the address has been sent.
//
while((HWREG(base + UART_O_FR) & (UART_FR_TXFE | UART_FR_BUSY)) !=
UART_FR_TXFE)
{
}
//
// Restore the address/data setting.
//
HWREG(base + UART_O_LCRH) = lcrh;
}
//*****************************************************************************
//
// UART_stop9BitDataMode()
//
//*****************************************************************************
void
UART_stop9BitDataMode(uint32_t base, uint32_t lcrh)
{
//
// Check the arguments.
//
ASSERT(UART_isBaseValid(base));
//
// Wait until the FIFO is empty and the UART is not busy.
//
while((HWREG(base + UART_O_FR) & (UART_FR_TXFE | UART_FR_BUSY)) !=
UART_FR_TXFE)
{
}
//
// Restore the address/data setting to enter normal transmission mode.
//
HWREG(base + UART_O_LCRH) = lcrh;
}
//*****************************************************************************
//
// UART_configure9BitDataMode()
//
//*****************************************************************************
uint32_t
UART_configure9BitDataMode(uint32_t base)
{
uint32_t lcrh;
//
// Check the arguments.
//
ASSERT(UART_isBaseValid(base));
//
// Wait until the FIFO is empty and the UART is not busy.
//
while((HWREG(base + UART_O_FR) & (UART_FR_TXFE | UART_FR_BUSY)) !=
UART_FR_TXFE)
{
}
//
// Force the address/data bit to 0 to indicate this is an data byte.
//
lcrh = HWREG(base + UART_O_LCRH);
HWREG(base + UART_O_LCRH) = (lcrh | UART_LCRH_EPS |
UART_LCRH_SPS | UART_LCRH_PEN);
//
// Needed to restore the address/data setting after the full
// 9-bit data transmission.
//
return(lcrh);
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,467 @@
//###########################################################################
//
// FILE: udma.c
//
// TITLE: Driver for the micro-DMA controller.
//
//###########################################################################
//
// 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 "udma.h"
//*****************************************************************************
//
// UDMA_enableChannelAttribute()
//
//*****************************************************************************
void
UDMA_enableChannelAttribute(uint32_t base, uint32_t channelNum,
uint32_t channelAttr)
{
//
// Check the arguments.
//
ASSERT(UDMA_isBaseValid(base));
ASSERT((channelNum & 0xFFFFU) < 32U);
ASSERT((channelAttr & ~(UDMA_CH_ATTR_USEBURST | UDMA_CH_ATTR_ALTSELECT |
UDMA_CH_ATTR_HIGH_PRIORITY | UDMA_CH_ATTR_REQMASK)) == 0U);
//
// Set the useburst bit for this channel if set in channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_USEBURST) == UDMA_CH_ATTR_USEBURST)
{
HWREG(base + UDMA_O_DMAUSEBURSTSET) = 1U << channelNum;
}
//
// Set the alternate control select bit for this channel,
// if set in channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_ALTSELECT) == UDMA_CH_ATTR_ALTSELECT)
{
HWREG(base + UDMA_O_DMAALTSET) = 1U << channelNum;
}
//
// Set the high priority bit for this channel, if set in channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_HIGH_PRIORITY) == UDMA_CH_ATTR_HIGH_PRIORITY)
{
HWREG(base + UDMA_O_DMAPRIOSET) = 1U << channelNum;
}
//
// Set the request mask bit for this channel, if set in channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_REQMASK) == UDMA_CH_ATTR_REQMASK)
{
HWREG(base + UDMA_O_DMAREQMASKSET) = 1U << channelNum;
}
}
//*****************************************************************************
//
// UDMA_disableChannelAttribute()
//
//*****************************************************************************
void
UDMA_disableChannelAttribute(uint32_t base, uint32_t channelNum,
uint32_t channelAttr)
{
//
// Check the arguments.
//
ASSERT(UDMA_isBaseValid(base));
ASSERT((channelNum & 0xFFFFU) < 32U);
ASSERT((channelAttr & ~(UDMA_CH_ATTR_USEBURST | UDMA_CH_ATTR_ALTSELECT |
UDMA_CH_ATTR_HIGH_PRIORITY | UDMA_CH_ATTR_REQMASK)) == 0U);
//
// Clear the useburst bit for this channel if set in channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_USEBURST) == UDMA_CH_ATTR_USEBURST)
{
HWREG(base + UDMA_O_DMAUSEBURSTCLR) = 1U << channelNum;
}
//
// Clear the alternate control select bit for this channel, if set in
// channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_ALTSELECT) == UDMA_CH_ATTR_ALTSELECT)
{
HWREG(base + UDMA_O_DMAALTCLR) = 1U << channelNum;
}
//
// Clear the high priority bit for this channel, if set in channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_HIGH_PRIORITY) == UDMA_CH_ATTR_HIGH_PRIORITY)
{
HWREG(base + UDMA_O_DMAPRIOCLR) = 1U << channelNum;
}
//
// Clear the request mask bit for this channel, if set in channelAttr.
//
if((channelAttr & UDMA_CH_ATTR_REQMASK) == UDMA_CH_ATTR_REQMASK)
{
HWREG(base + UDMA_O_DMAREQMASKCLR) = 1U << channelNum;
}
}
//*****************************************************************************
//
// UDMA_getChannelAttribute()
//
//*****************************************************************************
uint32_t
UDMA_getChannelAttribute(uint32_t base, uint32_t channelNum)
{
uint32_t channelAttr = 0U;
uint32_t offset = 1U << channelNum;
//
// Check the arguments.
//
ASSERT(UDMA_isBaseValid(base));
ASSERT((channelNum & 0xFFFFU) < 32U);
//
// Check to see if useburst bit is set for this channel.
//
if((HWREG(base + UDMA_O_DMAUSEBURSTSET) & offset) == offset)
{
channelAttr |= UDMA_CH_ATTR_USEBURST;
}
//
// Check to see if the alternate control bit is set for this channel.
//
if((HWREG(base + UDMA_O_DMAALTSET) & offset) == offset)
{
channelAttr |= UDMA_CH_ATTR_ALTSELECT;
}
//
// Check to see if the high priority bit is set for this channel.
//
if((HWREG(base + UDMA_O_DMAPRIOSET) & offset) == offset)
{
channelAttr |= UDMA_CH_ATTR_HIGH_PRIORITY;
}
//
// Check to see if the request mask bit is set for this channel.
//
if((HWREG(base + UDMA_O_DMAREQMASKSET) & offset) == offset)
{
channelAttr |= UDMA_CH_ATTR_REQMASK;
}
//
// Return the configuration flags.
//
return(channelAttr);
}
//*****************************************************************************
//
// UDMA_setChannelTransferParams()
//
//*****************************************************************************
extern void
UDMA_setChannelTransferParams(uint32_t base, uint32_t index, void *srcAddr,
void *dstAddr, uint32_t transferMode,
uint32_t transferSize)
{
UDMA_ControlTable *controlTable;
uint32_t chControlAttr;
uint32_t addrInc;
uint32_t bufferBytes;
uint32_t txModeTemp, srcAddrTemp, dstAddrTemp;
//
// Check the arguments.
//
ASSERT(UDMA_isBaseValid(base));
ASSERT(index < 64U);
ASSERT(HWREG(base + UDMA_O_DMACTLBASE) != 0U);
ASSERT(transferMode <= UDMA_MODE_PER_SCATTER_GATHER);
ASSERT((uint32_t)srcAddr >= 0x20000000U);
ASSERT((uint32_t)dstAddr >= 0x20000000U);
ASSERT((transferSize != 0U) && (transferSize <= 1024U));
//
// Get the base address of the control table.
//
controlTable = (UDMA_ControlTable *)HWREG(base + UDMA_O_DMACTLBASE);
ASSERT(controlTable != 0U);
//
// Get the current control word value and mask off the mode and size
// fields.
//
chControlAttr = (controlTable[index].chControlAttr &
~(UDMA_DMACHCTL_XFERSIZE_M | UDMA_DMACHCTL_XFERMODE_M));
//
// Adjust the mode if the alt control structure is selected.
//
if((index & UDMA_ALT_SELECT) == UDMA_ALT_SELECT)
{
if((transferMode == UDMA_MODE_MEM_SCATTER_GATHER) ||
(transferMode == UDMA_MODE_PER_SCATTER_GATHER))
{
txModeTemp = transferMode | UDMA_MODE_ALT_SELECT;
}
else
{
txModeTemp = transferMode;
}
}
else
{
txModeTemp = transferMode;
}
//
// Set the transfer size and mode in the control word (but don't write the
// control word yet as it could kick off a transfer).
//
chControlAttr |= txModeTemp |
((transferSize - 1U) << UDMA_DMACHCTL_XFERSIZE_S);
//
// Get the address increment value for the source, from the control word.
//
addrInc = (chControlAttr & UDMA_DMACHCTL_SRCINC_M);
//
// Compute the ending source address of the transfer. If the source
// increment is set to none, then the ending address is the same as the
// beginning.
//
if(addrInc != UDMA_SRC_INC_NONE)
{
addrInc = addrInc >> UDMA_DMACHCTL_SRCINC_S;
bufferBytes = transferSize << addrInc;
srcAddrTemp = ((uint32_t)srcAddr + bufferBytes - 1U);
}
else
{
srcAddrTemp = (uint32_t)srcAddr;
}
//
// Load the source ending address into the control block.
//
controlTable[index].srcEndAddr = (void *)srcAddrTemp;
//
// Get the address increment value for the destination, from the control
// word.
//
addrInc = chControlAttr & UDMA_DMACHCTL_DSTINC_M;
//
// Compute the ending destination address of the transfer. If the
// destination increment is set to none, then the ending address is the
// same as the beginning.
//
if(addrInc != UDMA_DST_INC_NONE)
{
//
// There is a special case if this is setting up a scatter-gather
// transfer. The destination pointer must point to the end of
// the alternate structure for this channel instead of calculating
// the end of the buffer in the normal way.
//
if((transferMode == UDMA_MODE_MEM_SCATTER_GATHER) ||
(transferMode == UDMA_MODE_PER_SCATTER_GATHER))
{
dstAddrTemp = (uint32_t)&controlTable[index |
UDMA_ALT_SELECT].spare;
}
//
// Not a scatter-gather transfer, calculate end pointer normally.
//
else
{
addrInc = addrInc >> UDMA_DMACHCTL_DSTINC_S;
bufferBytes = transferSize << addrInc;
dstAddrTemp = ((uint32_t)dstAddr + bufferBytes - 1U);
}
}
else
{
dstAddrTemp = (uint32_t)dstAddr;
}
//
// Load the destination ending address into the control block.
//
controlTable[index].dstEndAddr = (void *)dstAddrTemp;
//
// Write the new control word value.
//
controlTable[index].chControlAttr = chControlAttr;
}
//*****************************************************************************
//
// UDMA_getChannelTransferSize()
//
//*****************************************************************************
uint32_t
UDMA_getChannelTransferSize(uint32_t base, uint32_t index)
{
UDMA_ControlTable *controlTable;
uint32_t chControlAttr, txSize;
//
// Check the arguments.
//
ASSERT(UDMA_isBaseValid(base));
ASSERT((index & 0xFFFFU) < 64U);
ASSERT(HWREG(base + UDMA_O_DMACTLBASE) != 0U);
//
// Get the base address of the control table.
//
controlTable = (UDMA_ControlTable *)HWREG(base + UDMA_O_DMACTLBASE);
ASSERT(controlTable != 0U);
//
// Get the current control word value and mask off all but the size field
// and the mode field.
//
chControlAttr = (controlTable[index].chControlAttr &
(UDMA_DMACHCTL_XFERSIZE_M | UDMA_DMACHCTL_XFERMODE_M));
//
// If the size field and mode field are 0 then the transfer is finished
// and there are no more items to transfer
//
if(chControlAttr == 0U)
{
txSize = 0U;
}
//
// Otherwise, if either the size field or more field is non-zero, then
// not all the items have been transferred.
//
else
{
//
// Shift the size field and add one, then return to user.
//
txSize = (chControlAttr >> UDMA_DMACHCTL_XFERSIZE_S) + 1U;
}
return(txSize);
}
//*****************************************************************************
//
// UDMA_setChannelScatterGatherMode()
//
//*****************************************************************************
void
UDMA_setChannelScatterGatherMode(uint32_t base, uint32_t channelNum,
uint32_t taskCount, UDMA_ControlTable *taskList,
bool isPeriphScatterGather)
{
volatile UDMA_ControlTable *controlTable;
UDMA_ControlTable *taskTable;
//
// Check the parameters
//
ASSERT(UDMA_isBaseValid(base));
ASSERT(channelNum < 32U);
ASSERT(HWREG(base + UDMA_O_DMACTLBASE) != 0U);
ASSERT(taskList != 0U);
ASSERT((taskCount != 0U) && (taskCount <= 1024U));
//
// Get the base address of the control table.
//
controlTable = (UDMA_ControlTable *)HWREG(base + UDMA_O_DMACTLBASE);
//
// Get a handy pointer to the task list.
//
taskTable = taskList;
ASSERT(taskTable);
//
// Compute the ending address for the source pointer. This address is the
// last element of the last task in the task table.
//
controlTable[channelNum].srcEndAddr = &taskTable[taskCount - 1U].spare;
//
// Compute the ending address for the destination pointer. This address
// is the end of the alternate structure for this channel.
//
controlTable[channelNum].dstEndAddr = &controlTable[channelNum |
UDMA_ALT_SELECT].spare;
//
// Compute the control word. Most configurable items are fixed for
// scatter-gather. Item and increment sizes are all 32-bit and arb
// size must be 4. The count is the number of items in the task list
// times 4 (4 words per task).
//
controlTable[channelNum].chControlAttr =
(UDMA_DST_INC_32 | UDMA_SIZE_32 | UDMA_SRC_INC_32 | UDMA_ARB_4 |
((uint32_t)((taskCount * 4U) - 1U) << UDMA_DMACHCTL_XFERSIZE_S) |
((isPeriphScatterGather == true) ? UDMA_MODE_PER_SCATTER_GATHER :
UDMA_MODE_MEM_SCATTER_GATHER));
//
// Scatter-gather operations can leave the alt bit set. So if doing
// back to back scatter-gather transfers, the second attempt may not
// work correctly because the alt bit is set. Therefore, clear the
// alt bit here to ensure that it is always cleared before a new SG
// transfer is started.
//
HWREG(base + UDMA_O_DMAALTCLR) = 1U << channelNum;
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,577 @@
//###########################################################################
//
// FILE: usb.h
//
// TITLE: Prototypes for the USB Interface Driver.
//
//###########################################################################
//
//
//
// 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.
// $
//###########################################################################
#ifndef USB_H
#define USB_H
//*****************************************************************************
//
// If building with a C++ compiler, make all of the definitions in this header
// have a C binding.
//
//*****************************************************************************
#ifdef __cplusplus
extern "C"
{
#endif
//*****************************************************************************
//
//! \addtogroup usb_api USB
//! @{
//
//*****************************************************************************
//*****************************************************************************
//
// The following are defines for the g_usUSBFlags variable
//
//*****************************************************************************
#define USB_VBUS_VALID 0x0001U
#define USB_ID_HOST 0x0002U
#define USB_ID_DEVICE 0x0000U
#define USB_PFLT_ACTIVE 0x0004U
//*****************************************************************************
//
// The following are values that can be passed to USBIntEnableControl() and
// USBIntDisableControl() as the ui32Flags parameter, and are returned from
// USBIntStatusControl().
//
//*****************************************************************************
#define USB_INTCTRL_ALL 0x000003FFUL // All control interrupt sources
#define USB_INTCTRL_STATUS 0x000000FFUL // Status Interrupts
#define USB_INTCTRL_VBUS_ERR 0x00000080UL // VBUS Error
#define USB_INTCTRL_SESSION 0x00000040UL // Session Start Detected
#define USB_INTCTRL_SESSION_END 0x00000040UL // Session End Detected
#define USB_INTCTRL_DISCONNECT 0x00000020UL // Disconnect Detected
#define USB_INTCTRL_CONNECT 0x00000010UL // Device Connect Detected
#define USB_INTCTRL_SOF 0x00000008UL // Start of Frame Detected
#define USB_INTCTRL_BABBLE 0x00000004UL // Babble signaled
#define USB_INTCTRL_RESET 0x00000004UL // Reset signaled
#define USB_INTCTRL_RESUME 0x00000002UL // Resume detected
#define USB_INTCTRL_SUSPEND 0x00000001UL // Suspend detected
#define USB_INTCTRL_MODE_DETECT 0x00000200UL // Mode value valid
#define USB_INTCTRL_POWER_FAULT 0x00000100UL // Power Fault detected
//*****************************************************************************
//
// The following are values that can be passed to USBIntEnableEndpoint() and
// USBIntDisableEndpoint() as the ui32Flags parameter, and are returned from
// USBIntStatusEndpoint().
//
//*****************************************************************************
#define USB_INTEP_ALL 0xFFFFFFFFUL // Host IN Interrupts
#define USB_INTEP_HOST_IN 0xFFFE0000UL // Host IN Interrupts
#define USB_INTEP_HOST_IN_15 0x80000000UL // Endpoint 15 Host IN Interrupt
#define USB_INTEP_HOST_IN_14 0x40000000UL // Endpoint 14 Host IN Interrupt
#define USB_INTEP_HOST_IN_13 0x20000000UL // Endpoint 13 Host IN Interrupt
#define USB_INTEP_HOST_IN_12 0x10000000UL // Endpoint 12 Host IN Interrupt
#define USB_INTEP_HOST_IN_11 0x08000000UL // Endpoint 11 Host IN Interrupt
#define USB_INTEP_HOST_IN_10 0x04000000UL // Endpoint 10 Host IN Interrupt
#define USB_INTEP_HOST_IN_9 0x02000000UL // Endpoint 9 Host IN Interrupt
#define USB_INTEP_HOST_IN_8 0x01000000UL // Endpoint 8 Host IN Interrupt
#define USB_INTEP_HOST_IN_7 0x00800000UL // Endpoint 7 Host IN Interrupt
#define USB_INTEP_HOST_IN_6 0x00400000UL // Endpoint 6 Host IN Interrupt
#define USB_INTEP_HOST_IN_5 0x00200000UL // Endpoint 5 Host IN Interrupt
#define USB_INTEP_HOST_IN_4 0x00100000UL // Endpoint 4 Host IN Interrupt
#define USB_INTEP_HOST_IN_3 0x00080000UL // Endpoint 3 Host IN Interrupt
#define USB_INTEP_HOST_IN_2 0x00040000UL // Endpoint 2 Host IN Interrupt
#define USB_INTEP_HOST_IN_1 0x00020000UL // Endpoint 1 Host IN Interrupt
#define USB_INTEP_DEV_OUT 0xFFFE0000UL // Device OUT Interrupts
#define USB_INTEP_DEV_OUT_15 0x80000000UL // Endpoint 15 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_14 0x40000000UL // Endpoint 14 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_13 0x20000000UL // Endpoint 13 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_12 0x10000000UL // Endpoint 12 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_11 0x08000000UL // Endpoint 11 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_10 0x04000000UL // Endpoint 10 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_9 0x02000000UL // Endpoint 9 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_8 0x01000000UL // Endpoint 8 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_7 0x00800000UL // Endpoint 7 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_6 0x00400000UL // Endpoint 6 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_5 0x00200000UL // Endpoint 5 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_4 0x00100000UL // Endpoint 4 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_3 0x00080000UL // Endpoint 3 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_2 0x00040000UL // Endpoint 2 Device OUT Interrupt
#define USB_INTEP_DEV_OUT_1 0x00020000UL // Endpoint 1 Device OUT Interrupt
#define USB_INTEP_HOST_OUT 0x0000FFFEUL // Host OUT Interrupts
#define USB_INTEP_HOST_OUT_15 0x00008000UL // Endpoint 15 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_14 0x00004000UL // Endpoint 14 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_13 0x00002000UL // Endpoint 13 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_12 0x00001000UL // Endpoint 12 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_11 0x00000800UL // Endpoint 11 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_10 0x00000400UL // Endpoint 10 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_9 0x00000200UL // Endpoint 9 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_8 0x00000100UL // Endpoint 8 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_7 0x00000080UL // Endpoint 7 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_6 0x00000040UL // Endpoint 6 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_5 0x00000020UL // Endpoint 5 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_4 0x00000010UL // Endpoint 4 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_3 0x00000008UL // Endpoint 3 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_2 0x00000004UL // Endpoint 2 Host OUT Interrupt
#define USB_INTEP_HOST_OUT_1 0x00000002UL // Endpoint 1 Host OUT Interrupt
#define USB_INTEP_DEV_IN 0x0000FFFEUL // Device IN Interrupts
#define USB_INTEP_DEV_IN_15 0x00008000UL // Endpoint 15 Device IN Interrupt
#define USB_INTEP_DEV_IN_14 0x00004000UL // Endpoint 14 Device IN Interrupt
#define USB_INTEP_DEV_IN_13 0x00002000UL // Endpoint 13 Device IN Interrupt
#define USB_INTEP_DEV_IN_12 0x00001000UL // Endpoint 12 Device IN Interrupt
#define USB_INTEP_DEV_IN_11 0x00000800UL // Endpoint 11 Device IN Interrupt
#define USB_INTEP_DEV_IN_10 0x00000400UL // Endpoint 10 Device IN Interrupt
#define USB_INTEP_DEV_IN_9 0x00000200UL // Endpoint 9 Device IN Interrupt
#define USB_INTEP_DEV_IN_8 0x00000100UL // Endpoint 8 Device IN Interrupt
#define USB_INTEP_DEV_IN_7 0x00000080UL // Endpoint 7 Device IN Interrupt
#define USB_INTEP_DEV_IN_6 0x00000040UL // Endpoint 6 Device IN Interrupt
#define USB_INTEP_DEV_IN_5 0x00000020UL // Endpoint 5 Device IN Interrupt
#define USB_INTEP_DEV_IN_4 0x00000010UL // Endpoint 4 Device IN Interrupt
#define USB_INTEP_DEV_IN_3 0x00000008UL // Endpoint 3 Device IN Interrupt
#define USB_INTEP_DEV_IN_2 0x00000004UL // Endpoint 2 Device IN Interrupt
#define USB_INTEP_DEV_IN_1 0x00000002UL // Endpoint 1 Device IN Interrupt
#define USB_INTEP_0 0x00000001UL // Endpoint 0 Interrupt
//*****************************************************************************
//
// The following are values that are returned from USBSpeedGet().
//
//*****************************************************************************
#define USB_UNDEF_SPEED 0x80000000UL // Current speed is undefined
#define USB_FULL_SPEED 0x00000001UL // Current speed is Full Speed
#define USB_LOW_SPEED 0x00000000UL // Current speed is Low Speed
//*****************************************************************************
//
// The following are values that are returned from USBEndpointStatus(). The
// USB_HOST_* values are used when the USB controller is in host mode and the
// USB_DEV_* values are used when the USB controller is in device mode.
//
//*****************************************************************************
#define USB_HOST_IN_STATUS 0xFFFF0000UL // Mask of all host IN interrupts
#define USB_HOST_IN_PID_ERROR 0x10000000UL // Stall on this endpoint received
#define USB_HOST_IN_NOT_COMP 0x01000000UL // Device failed to respond
#define USB_HOST_IN_STALL 0x00400000UL // Stall on this endpoint received
#define USB_HOST_IN_DATA_ERROR 0x00080000UL // CRC or bit-stuff error
// (ISOC Mode)
#define USB_HOST_IN_NAK_TO 0x00080000UL // NAK received for more than the
// specified timeout period
#define USB_HOST_IN_ERROR 0x00040000UL // Failed to communicate with a
// device
#define USB_HOST_IN_FIFO_FULL 0x00020000UL // RX FIFO full
#define USB_HOST_IN_PKTRDY 0x00010000UL // Data packet ready
#define USB_HOST_OUT_STATUS 0x0000FFFFUL // Mask of all host OUT interrupts
#define USB_HOST_OUT_NAK_TO 0x00000080UL // NAK received for more than the
// specified timeout period
#define USB_HOST_OUT_NOT_COMP 0x00000080UL // No response from device
// (ISOC mode)
#define USB_HOST_OUT_STALL 0x00000020UL // Stall on this endpoint received
#define USB_HOST_OUT_ERROR 0x00000004UL // Failed to communicate with a
// device
#define USB_HOST_OUT_FIFO_NE 0x00000002UL // TX FIFO is not empty
#define USB_HOST_OUT_PKTPEND 0x00000001UL // Transmit still being transmitted
#define USB_HOST_EP0_NAK_TO 0x00000080UL // NAK received for more than the
// specified timeout period
#define USB_HOST_EP0_STATUS 0x00000040UL // This was a status packet
#define USB_HOST_EP0_ERROR 0x00000010UL // Failed to communicate with a
// device
#define USB_HOST_EP0_RX_STALL 0x00000004UL // Stall on this endpoint received
#define USB_HOST_EP0_RXPKTRDY 0x00000001UL // Receive data packet ready
#define USB_DEV_RX_PID_ERROR 0x01000000UL // PID error in isochronous
// transfer
#define USB_DEV_RX_SENT_STALL 0x00400000UL // Stall was sent on this endpoint
#define USB_DEV_RX_DATA_ERROR 0x00080000UL // CRC error on the data
#define USB_DEV_RX_OVERRUN 0x00040000UL // OUT packet was not loaded due to
// a full FIFO
#define USB_DEV_RX_FIFO_FULL 0x00020000UL // RX FIFO full
#define USB_DEV_RX_PKT_RDY 0x00010000UL // Data packet ready
#define USB_DEV_TX_NOT_COMP 0x00000080UL // Large packet split up, more data
// to come
#define USB_DEV_TX_SENT_STALL 0x00000020UL // Stall was sent on this endpoint
#define USB_DEV_TX_UNDERRUN 0x00000004UL // IN received with no data ready
#define USB_DEV_TX_FIFO_NE 0x00000002UL // The TX FIFO is not empty
#define USB_DEV_TX_TXPKTRDY 0x00000001UL // Transmit still being transmitted
#define USB_DEV_EP0_SETUP_END 0x00000010UL // Control transaction ended before
// Data End seen
#define USB_DEV_EP0_SENT_STALL 0x00000004UL // Stall was sent on this endpoint
#define USB_DEV_EP0_IN_PKTPEND 0x00000002UL // Transmit data packet pending
#define USB_DEV_EP0_OUT_PKTRDY 0x00000001UL // Receive data packet ready
//*****************************************************************************
//
// The following are values that can be passed to USBHostEndpointConfig() and
// USBDevEndpointConfigSet() as the ui32Flags parameter.
//
//*****************************************************************************
#define USB_EP_AUTO_SET 0x00000001UL // Auto set feature enabled
#define USB_EP_AUTO_REQUEST 0x00000002UL // Auto request feature enabled
#define USB_EP_AUTO_CLEAR 0x00000004UL // Auto clear feature enabled
#define USB_EP_DMA_MODE_0 0x00000008UL // Enable DMA access using mode 0
#define USB_EP_DMA_MODE_1 0x00000010UL // Enable DMA access using mode 1
#define USB_EP_MODE_ISOC 0x00000000UL // Isochronous endpoint
#define USB_EP_MODE_BULK 0x00000100UL // Bulk endpoint
#define USB_EP_MODE_INT 0x00000200UL // Interrupt endpoint
#define USB_EP_MODE_CTRL 0x00000300UL // Control endpoint
#define USB_EP_MODE_MASK 0x00000300UL // Mode Mask
#define USB_EP_SPEED_LOW 0x00000000UL // Low Speed
#define USB_EP_SPEED_FULL 0x00001000UL // Full Speed
#define USB_EP_HOST_IN 0x00000000UL // Host IN endpoint
#define USB_EP_HOST_OUT 0x00002000UL // Host OUT endpoint
#define USB_EP_DEV_IN 0x00002000UL // Device IN endpoint
#define USB_EP_DEV_OUT 0x00000000UL // Device OUT endpoint
//*****************************************************************************
//
// The following are values that can be passed to USBHostPwrConfig() as the
// ui32Flags parameter.
//
//*****************************************************************************
#define USB_HOST_PWRFLT_LOW 0x00000010UL
#define USB_HOST_PWRFLT_HIGH 0x00000030UL
#define USB_HOST_PWRFLT_EP_NONE 0x00000000UL
#define USB_HOST_PWRFLT_EP_TRI 0x00000140UL
#define USB_HOST_PWRFLT_EP_LOW 0x00000240UL
#define USB_HOST_PWRFLT_EP_HIGH 0x00000340UL
#define USB_HOST_PWREN_MAN_LOW 0x00000000UL
#define USB_HOST_PWREN_MAN_HIGH 0x00000001UL
#define USB_HOST_PWREN_AUTOLOW 0x00000002UL
#define USB_HOST_PWREN_AUTOHIGH 0x00000003UL
#define USB_HOST_PWREN_FILTER 0x00010000UL
//*****************************************************************************
//
// This value specifies the maximum size of transfers on endpoint 0 as 64
// bytes. This value is fixed in hardware as the FIFO size for endpoint 0.
//
//*****************************************************************************
#define MAX_PACKET_SIZE_EP0 64U
//*****************************************************************************
//
// These values are used to indicate which endpoint to access.
//
//*****************************************************************************
#define USB_EP_0 0x00000000UL // Endpoint 0
#define USB_EP_1 0x00000010UL // Endpoint 1
#define USB_EP_2 0x00000020UL // Endpoint 2
#define USB_EP_3 0x00000030UL // Endpoint 3
#define USB_EP_4 0x00000040UL // Endpoint 4
#define USB_EP_5 0x00000050UL // Endpoint 5
#define USB_EP_6 0x00000060UL // Endpoint 6
#define USB_EP_7 0x00000070UL // Endpoint 7
#define USB_EP_8 0x00000080UL // Endpoint 8
#define USB_EP_9 0x00000090UL // Endpoint 9
#define USB_EP_10 0x000000A0UL // Endpoint 10
#define USB_EP_11 0x000000B0UL // Endpoint 11
#define USB_EP_12 0x000000C0UL // Endpoint 12
#define USB_EP_13 0x000000D0UL // Endpoint 13
#define USB_EP_14 0x000000E0UL // Endpoint 14
#define USB_EP_15 0x000000F0UL // Endpoint 15
#define NUM_USB_EP 16U // Number of supported endpoints
//*****************************************************************************
//
// These macros allow conversion between 0-based endpoint indices and the
// USB_EP_x values required when calling various USB APIs.
//
//*****************************************************************************
#define IndexToUSBEP(x) (((uint32_t)(x) << 4U) & 0xFFU)
#define USBEPToIndex(x) ((x) >> 4U)
//*****************************************************************************
//
// The following are values that can be passed to USBFIFOConfigSet() as the
// ui32FIFOSize parameter.
//
//*****************************************************************************
#define USB_FIFO_SZ_8 0x00000000UL // 8 byte FIFO
#define USB_FIFO_SZ_16 0x00000001UL // 16 byte FIFO
#define USB_FIFO_SZ_32 0x00000002UL // 32 byte FIFO
#define USB_FIFO_SZ_64 0x00000003UL // 64 byte FIFO
#define USB_FIFO_SZ_128 0x00000004UL // 128 byte FIFO
#define USB_FIFO_SZ_256 0x00000005UL // 256 byte FIFO
#define USB_FIFO_SZ_512 0x00000006UL // 512 byte FIFO
#define USB_FIFO_SZ_1024 0x00000007UL // 1024 byte FIFO
#define USB_FIFO_SZ_2048 0x00000008UL // 2048 byte FIFO
#define USB_FIFO_SZ_4096 0x00000009UL // 4096 byte FIFO
#define USB_FIFO_SZ_8_DB 0x00000010UL // 8 byte double buffered FIFO
// (occupying 16 bytes)
#define USB_FIFO_SZ_16_DB 0x00000011UL // 16 byte double buffered FIFO
// (occupying 32 bytes)
#define USB_FIFO_SZ_32_DB 0x00000012UL // 32 byte double buffered FIFO
// (occupying 64 bytes)
#define USB_FIFO_SZ_64_DB 0x00000013UL // 64 byte double buffered FIFO
// (occupying 128 bytes)
#define USB_FIFO_SZ_128_DB 0x00000014UL // 128 byte double buffered FIFO
// (occupying 256 bytes)
#define USB_FIFO_SZ_256_DB 0x00000015UL // 256 byte double buffered FIFO
// (occupying 512 bytes)
#define USB_FIFO_SZ_512_DB 0x00000016UL // 512 byte double buffered FIFO
// (occupying 1024 bytes)
#define USB_FIFO_SZ_1024_DB 0x00000017UL // 1024 byte double buffered FIFO
// (occupying 2048 bytes)
#define USB_FIFO_SZ_2048_DB 0x00000018UL // 2048 byte double buffered FIFO
// (occupying 4096 bytes)
//*****************************************************************************
//
// This macro allow conversion from a FIFO size label as defined above to
// a number of bytes
//
//*****************************************************************************
#define USB_FIFO_SIZE_DB_FLAG 0x00000010UL
#define USBFIFOSizeToBytes(x) ((uint32_t)8U << (x))
//*****************************************************************************
//
// The following are values that can be passed to USBEndpointDataSend() as the
// ui32TransType parameter.
//
//*****************************************************************************
#define USB_TRANS_OUT 0x00000102UL // Normal OUT transaction
#define USB_TRANS_IN 0x00000102UL // Normal IN transaction
#define USB_TRANS_IN_LAST 0x0000010AUL // Final IN transaction (for
// endpoint 0 in device mode)
#define USB_TRANS_SETUP 0x0000110AUL // Setup transaction (for endpoint
// 0)
#define USB_TRANS_STATUS 0x00000142UL // Status transaction (for endpoint
// 0)
//*****************************************************************************
//
// The following are values are returned by the USBModeGet function.
//
//*****************************************************************************
#define USB_DUAL_MODE_HOST 0x00000001UL // Dual mode controller is in Host
// mode.
#define USB_DUAL_MODE_DEVICE 0x00000081UL // Dual mode controller is in
// Device mode.
#define USB_DUAL_MODE_NONE 0x00000080UL // Dual mode controller mode is not
// set.
#define USB_OTG_MODE_ASIDE_HOST 0x0000001DUL // OTG controller on the A side of
// the cable.
#define USB_OTG_MODE_ASIDE_NPWR 0x00000001UL // OTG controller on the A side of
// the cable.
#define USB_OTG_MODE_ASIDE_SESS 0x00000009UL // OTG controller on the A side of
// the cable Session Valid.
#define USB_OTG_MODE_ASIDE_AVAL 0x00000011UL // OTG controller on the A side of
// the cable A valid.
#define USB_OTG_MODE_ASIDE_DEV 0x00000019UL // OTG controller on the A side of
// the cable.
#define USB_OTG_MODE_BSIDE_HOST 0x0000009DUL // OTG controller on the B side of
// the cable.
#define USB_OTG_MODE_BSIDE_DEV 0x00000099UL // OTG controller on the B side of
// the cable.
#define USB_OTG_MODE_BSIDE_NPWR 0x00000081UL // OTG controller on the B side of
// the cable.
#define USB_OTG_MODE_NONE 0x00000080UL // OTG controller mode is not set.
//*****************************************************************************
//
//! The definition values are there to select the mask to pass as a parameter
//! to USBDMARawInterruptStatus().
//
//*****************************************************************************
# define USB_DMAA_RX_DONE 0x0U //!< USB uDMA A Rx Trigger Indication.
# define USB_DMAA_TX_DONE 0x1U //!< USB uDMA A Tx Trigger Indication.
# define USB_DMAB_RX_DONE 0x2U //!< USB uDMA B Rx Trigger Indication.
# define USB_DMAB_TX_DONE 0x3U //!< USB uDMA B Tx Trigger Indication.
# define USB_DMAC_RX_DONE 0x4U //!< USB uDMA C Rx Trigger Indication.
# define USB_DMAC_TX_DONE 0x5U //!< USB uDMA C Tx Trigger Indication.
//*****************************************************************************
//
// Prototypes for the APIs.
//
//*****************************************************************************
extern uint32_t USBDevAddrGet(uint32_t ui32Base);
extern void USBDevAddrSet(uint32_t ui32Base, uint32_t ui32Address);
extern void USBDevConnect(uint32_t ui32Base);
extern void USBDevDisconnect(uint32_t ui32Base);
extern void USBDevEndpointConfigSet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32MaxPacketSize,
uint32_t ui32Flags);
extern void USBDevEndpointConfigGet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t *pui32MaxPacketSize,
uint32_t *pui32Flags);
extern void USBDevEndpointDataAck(uint32_t ui32Base, uint32_t ui32Endpoint,
bool bIsLastPacket);
extern void USBDevEndpointStall(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern void USBDevEndpointStallClear(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern void USBDevEndpointStatusClear(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern uint32_t USBEndpointDataAvail(uint32_t ui32Base, uint32_t ui32Endpoint);
extern void USBEndpointDMAEnable(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern void USBEndpointDMADisable(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern void USBEndpointDMAConfigSet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Config);
extern int32_t USBEndpointDataGet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint8_t *pui8Data, uint32_t *pui32Size);
extern int32_t USBEndpointDataPut(uint32_t ui32Base, uint32_t ui32Endpoint,
uint8_t *pui8Data, uint32_t ui32Size);
extern int32_t USBEndpointDataSend(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32TransType);
extern void USBEndpointDataToggleClear(uint32_t ui32Base,
uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern void USBEndpointPacketCountSet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Count);
extern uint32_t USBEndpointStatus(uint32_t ui32Base, uint32_t ui32Endpoint);
extern uint32_t USBFIFOAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint);
extern void USBFIFOConfigGet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t *pui32FIFOAddress,
uint32_t *pui32FIFOSize, uint32_t ui32Flags);
extern void USBFIFOConfigSet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32FIFOAddress, uint32_t ui32FIFOSize,
uint32_t ui32Flags);
extern void USBFIFOFlush(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern uint32_t USBFrameNumberGet(uint32_t ui32Base);
extern uint32_t USBHostAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern void USBHostAddrSet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Addr, uint32_t ui32Flags);
extern void USBHostEndpointConfig(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32MaxPacketSize,
uint32_t ui32NAKPollInterval,
uint32_t ui32TargetEndpoint,
uint32_t ui32Flags);
extern void USBHostEndpointDataAck(uint32_t ui32Base,
uint32_t ui32Endpoint);
extern void USBHostEndpointDataToggle(uint32_t ui32Base, uint32_t ui32Endpoint,
bool bDataToggle, uint32_t ui32Flags);
extern void USBHostEndpointStatusClear(uint32_t ui32Base,
uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern uint32_t USBHostHubAddrGet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Flags);
extern void USBHostHubAddrSet(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Addr, uint32_t ui32Flags);
extern void USBHostPwrDisable(uint32_t ui32Base);
extern void USBHostPwrEnable(uint32_t ui32Base);
extern void USBHostPwrConfig(uint32_t ui32Base, uint32_t ui32Flags);
extern void USBHostPwrFaultDisable(uint32_t ui32Base);
extern void USBHostPwrFaultEnable(uint32_t ui32Base);
extern void USBHostRequestIN(uint32_t ui32Base, uint32_t ui32Endpoint);
extern void USBHostRequestINClear(uint32_t ui32Base, uint32_t ui32Endpoint);
extern void USBHostRequestStatus(uint32_t ui32Base);
extern void USBHostReset(uint32_t ui32Base, bool bStart);
extern void USBHostResume(uint32_t ui32Base, bool bStart);
extern uint32_t USBHostSpeedGet(uint32_t ui32Base);
extern void USBHostSuspend(uint32_t ui32Base);
extern void USBIntDisableControl(uint32_t ui32Base, uint32_t ui32IntFlags);
extern void USBIntEnableControl(uint32_t ui32Base, uint32_t ui32IntFlags);
extern uint32_t USBIntStatus(uint32_t ui32Base, uint32_t *ui32IntStatusEP);
extern uint32_t USBIntStatusControl(uint32_t ui32Base);
extern void USBIntDisableEndpoint(uint32_t ui32Base, uint32_t ui32IntFlags);
extern void USBIntEnableEndpoint(uint32_t ui32Base, uint32_t ui32IntFlags);
extern uint32_t USBIntStatusEndpoint(uint32_t ui32Base);
extern void USBOTGSessionRequest(uint32_t ui32Base, bool bStart);
extern uint32_t USBModeGet(uint32_t ui32Base);
extern void USBEndpointDMAChannel(uint32_t ui32Base, uint32_t ui32Endpoint,
uint32_t ui32Channel);
extern void USBHostMode(uint32_t ui32Base);
extern void USBDevMode(uint32_t ui32Base);
extern void USBOTGMode(uint32_t ui32Base);
extern void USBPHYPowerOff(uint32_t ui32Base);
extern void USBPHYPowerOn(uint32_t ui32Base);
extern uint32_t USBNumEndpointsGet(uint32_t ui32Base);
extern uint16_t USBDMARawInterruptStatus(uint32_t ui32Base);
extern void USBDMAInterruptMaskSet(uint32_t ui32Base, uint16_t intMaskValue);
extern void USBDMAInterruptMaskReset(uint32_t ui32Base, uint16_t intMaskValue);
extern uint16_t USBDMAInterruptStatus(uint32_t ui32Base);
extern void USBDMAInterruptStatusClear(uint32_t ui32Base, uint16_t intMask);
//*****************************************************************************
//
// The following are values that can be passed to USBIntEnable() and
// USBIntDisable() as the ulIntFlags parameter, and are returned from
// USBIntStatus().
//
//*****************************************************************************
#define USB_INT_ALL 0xFF030E0FUL // All Interrupt sources
#define USB_INT_STATUS 0xFF000000UL // Status Interrupts
#define USB_INT_VBUS_ERR 0x80000000UL // VBUS Error
#define USB_INT_SESSION_START 0x40000000UL // Session Start Detected
#define USB_INT_SESSION_END 0x20000000UL // Session End Detected
#define USB_INT_DISCONNECT 0x20000000UL // Disconnect Detected
#define USB_INT_CONNECT 0x10000000UL // Device Connect Detected
#define USB_INT_SOF 0x08000000UL // Start of Frame Detected
#define USB_INT_BABBLE 0x04000000UL // Babble signaled
#define USB_INT_RESET 0x04000000UL // Reset signaled
#define USB_INT_RESUME 0x02000000UL // Resume detected
#define USB_INT_SUSPEND 0x01000000UL // Suspend detected
#define USB_INT_MODE_DETECT 0x00020000UL // Mode value valid
#define USB_INT_POWER_FAULT 0x00010000UL // Power Fault detected
#define USB_INT_HOST_IN 0x00000E00UL // Host IN Interrupts
#define USB_INT_DEV_OUT 0x00000E00UL // Device OUT Interrupts
#define USB_INT_HOST_IN_EP3 0x00000800UL // Endpoint 3 Host IN Interrupt
#define USB_INT_HOST_IN_EP2 0x00000400UL // Endpoint 2 Host IN Interrupt
#define USB_INT_HOST_IN_EP1 0x00000200UL // Endpoint 1 Host IN Interrupt
#define USB_INT_DEV_OUT_EP3 0x00000800UL // Endpoint 3 Device OUT Interrupt
#define USB_INT_DEV_OUT_EP2 0x00000400UL // Endpoint 2 Device OUT Interrupt
#define USB_INT_DEV_OUT_EP1 0x00000200UL // Endpoint 1 Device OUT Interrupt
#define USB_INT_HOST_OUT 0x0000000EUL // Host OUT Interrupts
#define USB_INT_DEV_IN 0x0000000EUL // Device IN Interrupts
#define USB_INT_HOST_OUT_EP3 0x00000008UL // Endpoint 3 HOST_OUT Interrupt
#define USB_INT_HOST_OUT_EP2 0x00000004UL // Endpoint 2 HOST_OUT Interrupt
#define USB_INT_HOST_OUT_EP1 0x00000002UL // Endpoint 1 HOST_OUT Interrupt
#define USB_INT_DEV_IN_EP3 0x00000008UL // Endpoint 3 DEV_IN Interrupt
#define USB_INT_DEV_IN_EP2 0x00000004UL // Endpoint 2 DEV_IN Interrupt
#define USB_INT_DEV_IN_EP1 0x00000002UL // Endpoint 1 DEV_IN Interrupt
#define USB_INT_EP0 0x00000001UL // Endpoint 0 Interrupt
//*****************************************************************************
//
// Mark the end of the C bindings section for C++ compilers.
//
//*****************************************************************************
#ifdef __cplusplus
}
#endif
#endif // USB_H