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

Implementation of EVAL_POWRMS example for demo project. More...

#include "example.h"
#include "powrms_gpios.h"
#include "powrms_utils.h"
#include "powrms_data_processing.h"
#include "m24512.h"
#include "subscreen_blank_screen.h"
#include "no_os_alloc.h"
#include "no_os_delay.h"
#include "no_os_uart.h"
#include "no_os_print_log.h"
#include "maxim_uart_stdio.h"
#include "max32662.h"
Include dependency graph for example.c:

Macros

#define SCREEN_UPDATE_PERIOD_MS   200
 

Functions

void my_flush_cb (lv_display_t *disp, const lv_area_t *area, uint8_t *color_p)
 
int display_task ()
 Initialize the display task.
 
int configure_adc ()
 Configure the ADC.
 
int configure_display ()
 Configure the display.
 
int configure_debug_uart (void)
 Initialize the debug UART and route stdio (printf / pr_*) to it.
 
int screen_while ()
 IIO post-step callback.
 
int example_main (void)
 Main function.
 

Variables

LV_ATTRIBUTE_MEM_ALIGN uint8_t display_buffer [SSD1306_HOR_REZ *SSD1306_VER_REZ/8+8]
 
bool show_menu = 1
 
bool enter_pressed = 0
 
enum display_entry_t display_entry = DISPLAY_ENTRY_SHOW
 Display descriptor 0 -> Startup Frequency Screen 1 -> Main Screen (ADC values) 2 -> Show Screen 3 -> Settings Screen.
 

Detailed Description

Implementation of EVAL_POWRMS example for demo project.

Author
Robert Budai (rober.nosp@m.t.bu.nosp@m.dai@a.nosp@m.nalo.nosp@m.g.com)

Copyright 2025(c) Analog Devices, Inc.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. 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.
  3. Neither the name of Analog Devices, Inc. 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 ANALOG DEVICES, INC. “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 ANALOG DEVICES, INC. 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.

Macro Definition Documentation

◆ SCREEN_UPDATE_PERIOD_MS

#define SCREEN_UPDATE_PERIOD_MS   200

Function Documentation

◆ configure_adc()

int configure_adc ( )

Configure the ADC.

Returns
int

◆ configure_debug_uart()

int configure_debug_uart ( void )

Initialize the debug UART and route stdio (printf / pr_*) to it.

Uses the same UART that the IIO transport runs on (iio_demo_usb_ip) so that pr_info()/pr_debug()/pr_err() messages from the whole firmware appear on the host serial console.

Returns
int - 0 on success, negative error code on failure.

◆ configure_display()

int configure_display ( )

Configure the display.

Returns
int

◆ display_task()

int display_task ( )

Initialize the display task.

Returns
int

◆ example_main()

int example_main ( void )

Main function.

Basic example main execution.

Basic example main executiont.

Returns
int

IIO descriptor and initialization parameter.

IIO app.

Declaring iio_devices structure

Initializing IIO app init param.

Initializing IIO app.

Running the IIO app (use iio_info or osc in terminal).

Set the threshold voltage to 5V

The comparator output will be available on the GPO_A pin

Set the DAC output on channel C to 5V

Measure input current on channel D

GPIO Pin Interrupt Controller

UART init params

IIO application descriptor

IIO application initialization parameters

iio axi adc configurations.

iio axi dac configurations.

iio instance descriptor.

iio instance descriptor.

iio device instance descriptor.

UART init params

IIO application descriptor

IIO application initialization parameters

iio axi adc configurations.

iio axi dac configurations.

iio instance descriptor.

iio instance descriptor.

iio device instance descriptor.

Negative temperature

Positive temperature

Negative temperature

Positive temperature

Switch to APG mode

Switch to AWG mode

◆ my_flush_cb()

void my_flush_cb ( lv_display_t * disp,
const lv_area_t * area,
uint8_t * color_p )

◆ screen_while()

int screen_while ( )

IIO post-step callback.

Runs after every iio_step(). The heavy screen/ADC work is rate-limited to SCREEN_UPDATE_PERIOD_MS so it does not block the IIO transport on every poll. LVGL's tick is advanced with the real elapsed time rather than a fixed value.

Returns
int - always 0; a screen-side error must never tear down the IIO app.

Variable Documentation

◆ display_buffer

◆ display_entry

enum display_entry_t display_entry = DISPLAY_ENTRY_SHOW

Display descriptor 0 -> Startup Frequency Screen 1 -> Main Screen (ADC values) 2 -> Show Screen 3 -> Settings Screen.

◆ enter_pressed

bool enter_pressed = 0

◆ show_menu

bool show_menu = 1