LMA
Lightweight Metrology for AC
Loading...
Searching...
No Matches
Porting

Description

LMA Porting Layer

The LMA porting layer is used to perform most (ideally all) porting activities between platforms to enable LMA to run across different different cores. To perform a port, ensure you fulfill the functional requirements of the API in the porting files - using an existing port as reference may help.

Note
The documentation here is based on empty "skeleton" porting files and should be used to aid with creating a new port or navigating existing ports.

Files

file  LMA_Types.h
 Type definitions for LMA.
file  LMA_Port.h
 Porting file declarations for the LMA codebase.
file  LMA_Port.c
 Porting file definitions for the LMA codebase.

Macros

#define LMA_CRITICAL_SECTION_PREPARE()
 Macro to prepare function/code block for a crticial section.
#define LMA_CRITICAL_SECTION_ENTER()
 Macro used to enter critical section.
#define LMA_CRITICAL_SECTION_EXIT()
 Macro used to exit critical section.

Typedefs

typedef int32_t spl_t
 Raw ADC sample type.
typedef int64_t acc_t
 Accumulator type.

Functions

void LMA_AccPhaseRun (LMA_Phase *const p_phase)
 handles sample accumulation for a phase
void LMA_AccPhaseReset (LMA_Phase *const p_phase)
 handles sample reset between cycles for a phase
void LMA_AccPhaseLoad (LMA_Phase *const p_phase)
 Move accumulators from temp to snapshot.
void LMA_ADC_Init (void)
 Initialises ADC.
void LMA_ADC_Start (void)
 Starts the ADC running.
void LMA_ADC_Stop (void)
 Stops the ADC running.
void LMA_TMR_Init (void)
 Initialises TMR.
void LMA_TMR_Start (void)
 Starts the TMR running.
void LMA_TMR_Stop (void)
 Stops the TMR running.
void LMA_RTC_Init (void)
 Initialises RTC.
void LMA_RTC_Start (void)
 Starts the RTC running.
void LMA_RTC_Stop (void)
 Stops the RTC running.
void LMA_IMP_ActiveOn (void)
 Callback to turn on active impulse LED.
void LMA_IMP_ActiveOff (void)
 Callback to turn off active impulse LED.
void LMA_IMP_ReactiveOn (void)
 Callback to turn on reactive impulse LED.
void LMA_IMP_ReactiveOff (void)
 Callback to turn off reactive impulse LED.
void LMA_IMP_ApparentOn (void)
 Callback to turn on apparent impulse LED.
void LMA_IMP_ApparentOff (void)
 Callback to turn off apparent impulse LED.

Macro Definition Documentation

◆ LMA_CRITICAL_SECTION_PREPARE

#define LMA_CRITICAL_SECTION_PREPARE ( )

Macro to prepare function/code block for a crticial section.

Generally stores interrupt state information for restoration on exit of critical section.

◆ LMA_CRITICAL_SECTION_ENTER

#define LMA_CRITICAL_SECTION_ENTER ( )

Macro used to enter critical section.

Generally disables interrupts.

◆ LMA_CRITICAL_SECTION_EXIT

#define LMA_CRITICAL_SECTION_EXIT ( )

Macro used to exit critical section.

Generally restores interrupts state.

Typedef Documentation

◆ spl_t

typedef int32_t spl_t

Raw ADC sample type.

This type should accomodate the raw ADC sample type.

◆ acc_t

typedef int64_t acc_t

Accumulator type.

This type should accomodate the accumulation of the product of raw ADC sample types. Generally a good idea to be double the bit width of spl_t.

Function Documentation

◆ LMA_AccPhaseRun()

void LMA_AccPhaseRun ( LMA_Phase *const p_phase)

handles sample accumulation for a phase

Performs: vacc += v_sample ^ 2 iacc += i_sample ^ 2 pacc += i_sample * v_sample qacc += i_sample * v90_sample and where applicable iacc_neutral += i_neutral_sample ^ 2

Parameters
[in,out]p_phase- pointer to the phase we are working with.
Here is the caller graph for this function:

◆ LMA_AccPhaseReset()

void LMA_AccPhaseReset ( LMA_Phase *const p_phase)

handles sample reset between cycles for a phase

Performs: vacc = v_sample ^ 2 iacc = i_sample ^ 2 pacc = i_sample * v_sample qacc = i_sample * v90_sample and where applicable iacc_neutral = i_neutral_sample ^ 2

Parameters
[in,out]p_phase- pointer to the phase we are working with.
Here is the caller graph for this function:

◆ LMA_AccPhaseLoad()

void LMA_AccPhaseLoad ( LMA_Phase *const p_phase)

Move accumulators from temp to snapshot.

This could be done directly in LMA_Core, however with devices supporting hardware accumulator buffers, the temp values might not be stored where expected for efficiency. So we leave it to the porting layer to manage the accumulators in this way.

Parameters
[in,out]p_phase- pointer to the phase we are working with.
Here is the caller graph for this function:

◆ LMA_ADC_Init()

void LMA_ADC_Init ( void )

Initialises ADC.

Doesn't start it, just prepares it.

Here is the caller graph for this function:

◆ LMA_ADC_Start()

void LMA_ADC_Start ( void )

Starts the ADC running.

This function should start the ADC in a such a way that it results in a periodic "sampling complete" interrupt which enters the ISR that calls LMA_CB_ADC.

Here is the caller graph for this function:

◆ LMA_ADC_Stop()

void LMA_ADC_Stop ( void )

Stops the ADC running.

This function should stop the ADC in a such a way that it stops the periodic "sampling complete" interrupt which enters the ISR that calls LMA_CB_ADC.

Here is the caller graph for this function:

◆ LMA_TMR_Init()

void LMA_TMR_Init ( void )

Initialises TMR.

Doesn't start it, just prepares it.

Here is the caller graph for this function:

◆ LMA_TMR_Start()

void LMA_TMR_Start ( void )

Starts the TMR running.

This function should start the TMR in a such a way that it results in a periodic interrupt which enters the ISR that calls LMA_CB_TMR.

Here is the caller graph for this function:

◆ LMA_TMR_Stop()

void LMA_TMR_Stop ( void )

Stops the TMR running.

This function should stop the TMR in a such a way that it stops the periodic interrupt which enters the ISR that calls LMA_CB_TMR.

Here is the caller graph for this function:

◆ LMA_RTC_Init()

void LMA_RTC_Init ( void )

Initialises RTC.

Doesn't start it, just prepares it.

Here is the caller graph for this function:

◆ LMA_RTC_Start()

void LMA_RTC_Start ( void )

Starts the RTC running.

This function should start the RTC in a such a way that it results in a periodic interrupt which enters the ISR that calls LMA_CB_RTC.

Here is the caller graph for this function:

◆ LMA_RTC_Stop()

void LMA_RTC_Stop ( void )

Stops the RTC running.

This function should stop the RTC in a such a way that it stops the periodic interrupt which enters the ISR that calls LMA_CB_RTC.

Here is the caller graph for this function:

◆ LMA_IMP_ActiveOn()

void LMA_IMP_ActiveOn ( void )

Callback to turn on active impulse LED.

This function is called by the library to turn on the active impulse LED.

Here is the caller graph for this function:

◆ LMA_IMP_ActiveOff()

void LMA_IMP_ActiveOff ( void )

Callback to turn off active impulse LED.

This function is called by the library to turn off the active impulse LED.

Here is the caller graph for this function:

◆ LMA_IMP_ReactiveOn()

void LMA_IMP_ReactiveOn ( void )

Callback to turn on reactive impulse LED.

This function is called by the library to turn on the reactive impulse LED.

Here is the caller graph for this function:

◆ LMA_IMP_ReactiveOff()

void LMA_IMP_ReactiveOff ( void )

Callback to turn off reactive impulse LED.

This function is called by the library to turn off the reactive impulse LED.

Here is the caller graph for this function:

◆ LMA_IMP_ApparentOn()

void LMA_IMP_ApparentOn ( void )

Callback to turn on apparent impulse LED.

This function is called by the library to turn on the apparent impulse LED.

Here is the caller graph for this function:

◆ LMA_IMP_ApparentOff()

void LMA_IMP_ApparentOff ( void )

Callback to turn off apparent impulse LED.

This function is called by the library to turn off the apparent impulse LED.

Here is the caller graph for this function: