no-OS
Loading...
Searching...
No Matches
pilot.c File Reference

Pilot phase implementation file. More...

#include "no_os_print_log.h"
#include "interface.h"
#include "adc_reva.h"
#include "ade9113.h"
#include "pilot.h"
#include "gpio.h"
#include "tmr.h"
#include "adc.h"
#include "nvic_table.h"
Include dependency graph for pilot.c:

Functions

void TMR0_IRQHandler_CP ()
 TMR0 ISR.
 
void TMR1_IRQHandler_CP ()
 TMR1 ISR.
 
int get_pwm_low_flag_state (void)
 Get PWM low flag value.
 
uint32_t get_pwm_low_val (void)
 Get PWM LOW value.
 
uint32_t get_pwm_high_val (void)
 Get PWM HIGH value.
 
void reset_pwm_low_flag_state (void)
 Reset PWM low flag value.
 
int pilot_init (struct stout *stout)
 Initialize pilot phase.
 
void pilot_pwm_timer_setup (unsigned int duty_cycle)
 Set PMW parameters.
 
int pilot_interrupts_setup (struct no_os_irq_ctrl_desc *desc, struct stout *stout)
 Set pilot CP analog read interrupts.
 
void pilot_pwm_timer_set_duty_cycle (struct stout *stout, unsigned int duty_cycle)
 Set PMW duty cycle.
 
int pilot_setup_adc (void)
 Set PMW duty cycle.
 
unsigned int pilot_read_val (void)
 Read PWM voltage value.
 
uint32_t pilot_convert_to_mv (uint32_t value)
 Compute ADC voltage value.
 
uint32_t pilot_compute_average (uint8_t high)
 Compute PWM value average.
 
int pilot_write_new_values (struct stout *stout)
 Update PWM values in the state machine structure.
 
void pilot_update_vals (void)
 Update PWM values.
 
uint32_t get_count_ms (void)
 
void reset_count_ms (void)
 

Variables

struct no_os_irq_ctrl_desc * stout_nvic_desc
 

Detailed Description

Pilot phase implementation file.

Author
GMois (georg.nosp@m.e.mo.nosp@m.is@an.nosp@m.alog.nosp@m..com), REtz (radu..nosp@m.etz@.nosp@m.analo.nosp@m.g.co.nosp@m.m)

Copyright (c) 2023 Analog Devices, Inc.

SPDX-License-Identifier: BSD-3-Clause

Function Documentation

◆ get_count_ms()

uint32_t get_count_ms ( void )

Get milliseconds count

◆ get_pwm_high_val()

uint32_t get_pwm_high_val ( void )

Get PWM HIGH value.

Returns
PWM HIGH value

◆ get_pwm_low_flag_state()

int get_pwm_low_flag_state ( void )

Get PWM low flag value.

Returns
flag value

◆ get_pwm_low_val()

uint32_t get_pwm_low_val ( void )

Get PWM LOW value.

Returns
PWM LOW value

◆ pilot_compute_average()

uint32_t pilot_compute_average ( uint8_t high)

Compute PWM value average.

Parameters
high- 1 - HIGH PWM value
  • 0 - LOW PWM value
Returns
average value comouted from last read values

◆ pilot_convert_to_mv()

uint32_t pilot_convert_to_mv ( uint32_t value)

Compute ADC voltage value.

Parameters
value- rad ADC value
Returns
ADC value in mV

◆ pilot_init()

int pilot_init ( struct stout * stout)

Initialize pilot phase.

Returns
0 in case of success, error code otherwise

◆ pilot_interrupts_setup()

int pilot_interrupts_setup ( struct no_os_irq_ctrl_desc * desc,
struct stout * stout )

Set pilot CP analog read interrupts.

Parameters
desc- NVIC IRQ controller description
stout- the stout device structure
Returns
0 in case of success, error code otherwise

◆ pilot_pwm_timer_set_duty_cycle()

void pilot_pwm_timer_set_duty_cycle ( struct stout * stout,
unsigned int duty_cycle )

Set PMW duty cycle.

Parameters
stout- state machine descriptor
duty_cycle- duty cycle of output PWM times 10

◆ pilot_pwm_timer_setup()

void pilot_pwm_timer_setup ( unsigned int duty_cycle)

Set PMW parameters.

Parameters
duty_cycle- duty cycle of output PWM

◆ pilot_read_val()

unsigned int pilot_read_val ( void )

Read PWM voltage value.

Returns
ADC value

◆ pilot_setup_adc()

int pilot_setup_adc ( void )

Set PMW duty cycle.

Setup PWM voltage CP analog ADC

Returns
0 in case of success, error code otherwise

◆ pilot_update_vals()

void pilot_update_vals ( void )

Update PWM values.

Update PWM values

◆ pilot_write_new_values()

int pilot_write_new_values ( struct stout * stout)

Update PWM values in the state machine structure.

Parameters
stout- state machine descriptor
Returns
ADC value in mV

◆ reset_count_ms()

void reset_count_ms ( void )

Reset milliseconds count

◆ reset_pwm_low_flag_state()

void reset_pwm_low_flag_state ( void )

Reset PWM low flag value.

Reset PWM low flag value.

◆ TMR0_IRQHandler_CP()

void TMR0_IRQHandler_CP ( )

TMR0 ISR.

◆ TMR1_IRQHandler_CP()

void TMR1_IRQHandler_CP ( )

TMR1 ISR.

Variable Documentation

◆ stout_nvic_desc

struct no_os_irq_ctrl_desc* stout_nvic_desc
extern