|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
ADC_B VREF-channel sample-and-log demo for EK-RA8D2. More...
#include <stdint.h>#include "ra8_adc.h"#include "ra8_attributes.h"#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_isr.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | adc_b_demo_const_t : uint32_t { k_adc_b_demo_baud = 115200U , k_adc_b_demo_period_ms = 500U , k_adc_b_demo_vref_mv = 3300U , k_adc_b_demo_full_scale = 4095U } |
| Demo tunables. More... | |
| enum | adc_b_demo_chan_t : uint8_t { k_adc_b_demo_channel = 0U } |
| ADC channel selection. More... | |
| enum | adc_b_demo_fmt_t : uint8_t { k_adc_b_demo_dec_digits = 5U , k_adc_b_demo_line_max = 32U , k_adc_b_demo_radix = 10U , k_adc_b_demo_cr = '\r' , k_adc_b_demo_lf = '\n' } |
| Formatting constants. More... | |
Functions | |
| static uint32_t | internal_u16_to_dec (uint8_t *buf, uint16_t val) |
| Write the decimal digits of a 16-bit value into a byte buffer. | |
| static void | internal_panic_halt (void) |
| Park the core after an unrecoverable ADC demo failure. | |
| static void | internal_setup_or_halt (void) |
| Initialize clocks, SysTick, SCI8, and LED1. | |
| static ra8_err_t | internal_arm (void) |
| Configure ADC_B in 12-bit software-trigger mode. | |
| void | main (void) |
| Sample ADC_B and report raw and converted values continuously. | |
Variables | |
| static const uint8_t | s_adc_b_demo_log_prefix [] = "adc: raw=" |
| static const uint8_t | s_adc_b_demo_mv_sep [] = " mv=" |
| static const uint8_t | s_adc_b_demo_pass_msg [] = "adc: read PASS\r\n" |
| Verdict line emitted only after a successful channel read. | |
ADC_B VREF-channel sample-and-log demo for EK-RA8D2.
Configures the ADC_B in 12-bit, software-trigger mode, samples the internal VREF channel (k_adc_b_demo_channel) once per loop, and logs the raw count plus the converted millivolt value over SCI8.
Bring-up sequence:
Bare EK-RA8D2; no expansion board.
Definition in file main.c.
| enum adc_b_demo_chan_t : uint8_t |
| enum adc_b_demo_const_t : uint32_t |
| enum adc_b_demo_fmt_t : uint8_t |
|
staticnodiscard |
Configure ADC_B in 12-bit software-trigger mode.
Supplies the fixed resolution, trigger, alignment, and single-scan policy to the configured ADC initialization API.
| k_ra8_ok | ADC_B accepted the fixed demo configuration. |
| (other) | ADC_B initialization failed or rejected the configuration. |
Definition at line 179 of file main.c.
References k_ra8_adc_res_12bit, k_ra8_adc_trig_software, ra8_adc_init_configured(), and RA8_INTERNAL.
Referenced by main().
|
static |
Park the core after an unrecoverable ADC demo failure.
Repeatedly executes WFI, preserving failure state for a debugger.
Definition at line 123 of file main.c.
References RA8_INTERNAL.
Referenced by internal_clocks_or_halt(), internal_clocks_or_halt(), internal_setup_or_halt(), and main().
|
static |
Initialize clocks, SysTick, SCI8, and LED1.
Brings dependencies up in order and parks on the first HAL error.
Definition at line 140 of file main.c.
References internal_panic_halt(), k_adc_b_demo_baud, k_ra8_board_led1, k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_board_led_init(), ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), RA8_INTERNAL, and ra8_time_init().
|
static |
Write the decimal digits of a 16-bit value into a byte buffer.
Handles zero explicitly; otherwise collects least-significant digits in a bounded local array and reverses them into the caller's destination without appending a NUL terminator.
| [out] | buf | Destination with room for five decimal digits. |
| [in] | val | Value to convert. |
| 1 | Zero or a single-digit value was written. |
| 2..5 | The exact digit count of a larger value. |
Definition at line 93 of file main.c.
References k_adc_b_demo_dec_digits, k_adc_b_demo_radix, and RA8_INTERNAL.
Referenced by main().
| void main | ( | void | ) |
Sample ADC_B and report raw and converted values continuously.
The application entry point Reset_Handler hands control to.
Initializes and arms ADC_B, formats each successful channel sample without variadic I/O, emits the verdict, toggles LED1, and delays.
Definition at line 201 of file main.c.
References internal_arm(), internal_panic_halt(), internal_setup_or_halt(), internal_u16_to_dec(), k_adc_b_demo_channel, k_adc_b_demo_cr, k_adc_b_demo_full_scale, k_adc_b_demo_lf, k_adc_b_demo_line_max, k_adc_b_demo_period_ms, k_adc_b_demo_vref_mv, k_ra8_board_led1, k_ra8_ok, ra8_adc_read_channel(), ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), ra8_isr_globals_enable(), s_adc_b_demo_log_prefix, s_adc_b_demo_mv_sep, and s_adc_b_demo_pass_msg.
|
static |
|
static |