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.
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. |
#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.
#define LMA_CRITICAL_SECTION_ENTER | ( | ) |
Macro used to enter critical section.
Generally disables interrupts.
#define LMA_CRITICAL_SECTION_EXIT | ( | ) |
Macro used to exit critical section.
Generally restores interrupts state.
typedef int32_t spl_t |
Raw ADC sample type.
This type should accomodate the raw ADC sample type.
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.
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
[in,out] | p_phase | - pointer to the phase we are working with. |
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
[in,out] | p_phase | - pointer to the phase we are working with. |
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.
[in,out] | p_phase | - pointer to the phase we are working with. |
void LMA_ADC_Init | ( | void | ) |
Initialises ADC.
Doesn't start it, just prepares it.
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.
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.
void LMA_TMR_Init | ( | void | ) |
Initialises TMR.
Doesn't start it, just prepares it.
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.
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.
void LMA_RTC_Init | ( | void | ) |
Initialises RTC.
Doesn't start it, just prepares it.
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.
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.
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.
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.
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.
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.
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.
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.