ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_board_ek_ra8d2_pdm.c
Go to the documentation of this file.
1
15
16#include <stdint.h>
17
18#include "ra8_board_ek_ra8d2.h"
19#include "ra8_pdm.h"
20#include "ra8_port_constants.h"
21#include "ra8_port_utils.h"
22
23typedef enum : uint32_t {
26
27typedef enum : uint8_t {
30
33
34/* NOLINTBEGIN(readability-magic-numbers) -- HUM Table 49.7 row and reset filter coefficients. */
36 .sinc_order = 4U,
37 .clock_div = 0U,
38 .sinc_dec = 0x7CU,
39 .sinc_range = 0x05U,
40 .data_shift = 0U,
41 .edge = 0U,
42 .hpf_shift = 0U,
43 .cf_shift = 0U,
44 .lpf_shift = 0U,
45 .rx_threshold = 4U,
46 .hpf_s0 = 0x3F61U,
47 .hpf_k1 = 0x3EC1U,
48 .hpf_h = {0x4000U, 0xC000U},
49 .comp_h = {0x1FE8U,
50 0x0039U,
51 0x003CU,
52 0x1E56U,
53 0x01DCU,
54 0x06E1U,
55 0x01DCU,
56 0x1E56U,
57 0x003CU,
58 0x0039U,
59 0x1FE8U},
60 .lpf_h0 = 0x0400U,
61 .lpf_h1 = {0x1FF8U, 0x000AU, 0x1FF0U, 0x0018U, 0x1FDCU, 0x0034U, 0x1FB3U,
62 0x0076U, 0x1F2EU, 0x0289U, 0x0289U, 0x1F2EU, 0x0076U, 0x1FB3U,
63 0x0034U, 0x1FDCU, 0x0018U, 0x1FF0U, 0x000AU, 0x1FF8U},
64};
65/* NOLINTEND(readability-magic-numbers) */
66
68{
70 if (err != k_ra8_ok) {
71 return err;
72 }
74 return err;
75}
76
79{
80 if (out_config == nullptr) {
81 return k_ra8_err_null_ptr;
82 }
83 if ((uint8_t)microphone >= (uint8_t)k_ra8_board_pdm_mic_count) {
85 }
86 *out_config = (ra8_board_pdm_mic_config_t){
88 .sample_rate_hz = (uint32_t)k_board_pdm_sample_rate_hz,
89 .channel = (uint8_t)k_ra8_pdm_ch2,
90 .valid_bits = (uint8_t)k_board_pdm_valid_bits,
91 };
92 out_config->pdm.edge = (microphone == k_ra8_board_pdm_mic1) ? (uint8_t)0U : (uint8_t)1U;
93 return k_ra8_ok;
94}
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
static const ra8_pdm_channel_cfg_t s_board_pdm_sph0690
ra8_err_t ra8_board_pdm_mic_get_config(ra8_board_pdm_mic_t microphone, ra8_board_pdm_mic_config_t *out_config)
Return the validated SPH0690 filter policy for one board microphone.
static const ra8_port_pin_t s_board_pdm_pin_dat
ra8_err_t ra8_board_pdm_mic_route(void)
Route P812/P502 to PDMCLK2/PDMDAT2.
@ k_board_pdm_sample_rate_hz
Decimated SPH0690 sample rate.
ra8_board_pdm_width_t
@ k_board_pdm_valid_bits
PDM-IF signed PCM payload width.
static const ra8_port_pin_t s_board_pdm_pin_clk
ra8_board_pdm_mic_t
Selects one of the two SPH0690 microphones sharing PDM channel 2.
@ k_ra8_board_pdm_mic1
Rising-edge MIC1 (SELECT tied low).
@ k_ra8_board_pdm_mic_count
Number of on-board PDM microphones.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
Definition ra8_err.h:478
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
@ k_ra8_psel_pdm
11011b: PDM-IF (PDMCLKn / PDMDATn).
Pulse Density Modulation Interface (PDM-IF) capture driver.
@ k_ra8_pdm_ch2
Channel 2 (EK-RA8D2 MEMS mic).
Definition ra8_pdm.h:59
Typed Port / Pin Constants for the RA8D2 IOPORT Module.
ra8_port_pin_t
Packed (port << 8) | pin pin identifier.
@ k_ra8_port_5
RA8 port 5.
@ k_ra8_port_8
RA8 port 8.
#define RA8_PIN(port, pin)
Build a ra8_port_pin_t from explicit port / pin indices.
@ k_ra8_pin_2
RA8 pin 2.
@ k_ra8_pin_12
RA8 pin 12.
High-level GPIO helpers on top of the PORT + PFS register layer.
ra8_err_t ra8_pfs_route_peripheral(ra8_port_pin_t pin, ra8_psel_t psel, const char *owner)
Route a pin to a non-IRQ peripheral function via PFS.PSEL.
Definition gpio.c:238
Board-owned PDM mechanism configuration for one microphone.
ra8_pdm_channel_cfg_t pdm
SPH0690 filter coefficients.
One PDM channel's mode + filter configuration.
Definition ra8_pdm.h:93
uint8_t edge
0: rise-edge ch n; 1: fall-edge ch n-1 (INPSEL).
Definition ra8_pdm.h:99