This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TIDM-02011: Driverlib for LFU related registers

Part Number: TIDM-02011
Other Parts Discussed in Thread: C2000WARE

Dear Champs,

I am asking this for our customer.

There are many useful functions defined in buck_lfu.h for LFU related registers.

That is,

#pragma FUNC_ALWAYS_INLINE(BUCK_LFU_getBackgroundTaskControlRegister);
static inline uint16_t BUCK_LFU_getBackgroundTaskControlRegister(uint32_t base)
{
    //
	// Return the background task control register value
	//
    return((HWREGH(base + CLA_O_MCTLBGRND) & (uint16_t)CLA_MCTLBGRND_BGSTART));
}
#endif

static inline void
LFU_setLFUCPU(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set LFU_CPU bit
    //
	EALLOW;
    HWREGH(base + LFUConfig) |= LFU_CPU;
	EDIS;
}

static inline void
LFU_setLFUCLA(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set LFU_CLA1 bit
    //
	EALLOW;
    HWREGH(base + LFUConfig) |= LFU_CLA1;
	EDIS;
}

static inline void
LFU_setPieVectorSwap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set PieVectorSwap bit
    //
	EALLOW;
    HWREG(base + LFUConfig) |= PieVectorSwap;
	EDIS;
}

static inline void
LFU_setLS01Swap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set LS01Swap bit
    //
	EALLOW;
    HWREG(base + LFUConfig) |= LS01Swap;
	EDIS;
}

static inline void
LFU_setSwap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set PieVectorSwap and LS01Swap bits
    //
    EALLOW;
    HWREG(base + LFUConfig) |= SWAPS;
    EDIS;
}

static inline void
LFU_clearSwap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Clear PieVectorSwap and LS01Swap bits
    //
    EALLOW;
    HWREG(base + LFUConfig) &= ~(SWAPS);
    EDIS;
}


static inline void
LFU_clearLFUCPU(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set LFU_CPU bit
    //
	EALLOW;
    HWREGH(base + LFUConfig) &= ~(LFU_CPU);
	EDIS;
}

static inline void
LFU_clearLFUCLA(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set LFU_CLA1 bit
    //
	EALLOW;
    HWREGH(base + LFUConfig) &= ~(LFU_CLA1);
	EDIS;
}

static inline void
LFU_clearPieVectorSwap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Set PieVectorSwap bit
    //
	EALLOW;
    HWREG(base + LFUConfig) &= ~(PieVectorSwap);
	EDIS;
}

static inline void
LFU_clearLS01Swap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Clear LS01Swap bit
    //
	EALLOW;
    HWREG(base + LFUConfig) &= ~(LS01Swap);
	EDIS;
}

static inline uint32_t
LFU_getPieVectorSwap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Get PieVectorSwap bit
    //
	
    return((HWREG(base + LFUStatus)) & (uint32_t)PieVectorSwap);
}

static inline uint32_t
LFU_getLS01Swap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Get LS01Swap bit
    //
	return((HWREG(base + LFUStatus)) & (uint32_t)LS01Swap);
}

static inline uint16_t
LFU_getLFUCPU(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Get LFU_CPU bit
    //
    return((HWREGH(base + LFUConfig)) & (uint16_t)LFU_CPU);
}

static inline uint16_t
LFU_getLFUCLA(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Get LFU_CLA1 bit
    //
    return((HWREGH(base + LFUConfig)) & (uint16_t)LFU_CLA1);
}

static inline uint32_t
LFU_getSwap(uint32_t base)
{
    //
    // Check the arguments.
    //
    //ASSERT(SCI_isBaseValid(base));

    //
    // Get PieVectorSwap bit
    //

    return((HWREG(base + LFUStatus)) & (uint32_t)SWAPS);
}


// 
// Function to register an ISR into the Shadow PIE vector table (for LFU)
// for registering into the main/normal PIE vector table, Interrupt_Register() can be used
//
static inline void
Shadow_Interrupt_register(uint32_t interruptNumber, void (*handler)(void))
{
    uint32_t address;

    //
    // Calculate appropriate address for the interrupt number
    //
    address = (uint32_t)SHADOW_PIEVECTTABLE_BASE +
              (((interruptNumber & 0xFFFF0000U) >> 16U) * 2U);

    //
    // Copy ISR address into PIE table
    //
    EALLOW;
    HWREG(address) = (uint32_t)handler;
    EDIS;
}

Questions:

1. Should the user copy all these functions? Are there equivalent driverlib APIs for these? If not, can we add them in the driverlib? 

  • Wayne,

    Most of the LFU function shown here are now supported in sysctl.h and hw_sysctl.h files in driverlib. It should be straight forward to migrate these. Let us know if there are any specific functions pertaining to LFU that are still missing.

    Regards,

    Ozino

  • Wayne, Ozino,

    Correct, I had made a note of this in my notes, since back then C2000Ware didn’t have these functions supported, so I had to add and include them into our solution.

    So yes, we can (and will need to) leverage the C2000Ware functions directly, and remove them from the solution. If there are any differences, we will need to get them supported in Driverlib.

    Off the top of my head, I think there was one function I created – which sets (or clears) both the PIE swap and RAM swap together. I don’t believe we have this in Driverlib.

    Thanks,

    Sira

  • Dear Ozino, Sira,

    I checked the latest C2000ware V4.03 driverlib.

    I do see PIE and LS0/LS1 swap related API.

    But it seems there is no "Shadow_Interrupt_register(uint32_t interruptNumber, void (*handler)(void))", which is needed and useful for LFU.

    Do you see it?

    Wayne

  • Wayne, Ozino,

    I agree this will be useful as well.

    - LFU_Get/SetSwap()

    - Shadow_Interrupt_Register()

    Thanks,

    Sira